I have doubt whether it is possible to stop service , when USB is connected to PC?
if(intent.getAction().equals(Intent.ACTION_UMS_DISCONNECTED)) {
Intent intent2=new Intent(context,MyService.class);
context.startActivity(intent2);
}
else if (intent.getAction().equals( Intent.ACTION_UMS_CONNECTED)) {
stopService(new Intent(this, MyService.class));
}
I have given this, but it didn’t work.
Try another broadcast recever;
Hope this helps.