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?
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.
deixe-me dizer algumas palavras