Cannot resolve getIntent() method in Accessibility Service class

Shivansh Khare :

I am trying to send data from main activity to accessibility service class using intent but accessibility service class does not recognize getIntent() method. Is there any other way to pass data to an Accessibility Service class?

Fadzli Razali :

Make sure you add below code, where you want to start

Intent intent = new Intent(getApplicationContext(), AccessibilityService.class);
    intent.putExtra("data","value");
    startService(intent);

In your AccessibilityService class, make sure you override onStartCommand() method

@Override
public int onStartCommand(Intent intent, int flags, int startId) {
    super.onStartCommand(intent, flags, startId);
    String data="";
    if(intent.getExtras().containsKey("data"))
        data = intent.getStringExtra("data");
    return START_STICKY;
}

Este artigo é coletado da Internet.

Se houver alguma infração, entre em [email protected] Delete.

editar em
0

deixe-me dizer algumas palavras

0comentários
loginDepois de participar da revisão

Artigos relacionados

Cannot resolve method addOnCompleteListener

Getting a 'Cannot resolve method' error

Cannot resolve method 'toString(void)'

Google Maps v2- Cannot resolve method getSupportFragmentManager() on non-Activity class

Unable to resolve service for type for generic class

Cannot resolve method findViewByID(int) fragment java

Mockito MockedStatic when() "Cannot resolve method"

cannot resolve method 'get key' in Pair in android?

Cannot find the Resolve<T> method in UnityContainer

"How to fix 'Cannot resolve method "iterations and getFeatureMatrix "'?

loginButton.registerCallback cannot resolve method

Cannot resolve method 'formKey' in ACRA 4.7.0

Cannot resolve method addsnapshot listener in android

Java- Cannot resolve stopwatch class

Cannot resolve class TextView, ImageView, LinearLayout,

Android Studio Error "Cannot resolve method for method .add"

Method cannot be called inside of a class

Using UiAutomation from an accessibility service

Return Observable<boolean> from service method after two subscriptions resolve

Android global variable vs cannot resolve method getApplication()

Is there a Standardized method of Form Accessibility and Semantics?

Cannot autowire service "App\Service\MatchCarAdService": argument "$templating" of method

How test a void method into Service class, with Mockito?

Why abstract class cannot have Sealed method

cannot find symbol for method in a class of array objects

Cannot access method from another java class

Xamarin Android Accessibility Service Leaks Memory

Different accessibility of method based on how it is declared

"Cannot invoke method on null object" when injecting service into a controller