You've already forked android_translation_layer
mirror of
https://gitlab.com/android_translation_layer/android_translation_layer.git
synced 2025-10-27 11:48:10 -07:00
implement Context.stopService()
This commit is contained in:
@@ -10,6 +10,10 @@ public abstract class Service extends Context {
|
|||||||
System.out.println("Service.onCreate() called");
|
System.out.println("Service.onCreate() called");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void onDestroy() {
|
||||||
|
System.out.println("Service.onDestroy() called");
|
||||||
|
}
|
||||||
|
|
||||||
public abstract IBinder onBind(Intent intent);
|
public abstract IBinder onBind(Intent intent);
|
||||||
|
|
||||||
public abstract int onStartCommand(Intent intent, int flags, int startId);
|
public abstract int onStartCommand(Intent intent, int flags, int startId);
|
||||||
|
|||||||
@@ -553,7 +553,15 @@ public class Context extends Object {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean stopService(Intent intent) {return false;}
|
public boolean stopService(Intent intent) throws ClassNotFoundException {
|
||||||
|
Class<? extends Service> cls = Class.forName(intent.getComponent().getClassName()).asSubclass(Service.class);
|
||||||
|
Service service = runningServices.remove(cls);
|
||||||
|
if (service != null) {
|
||||||
|
service.onDestroy();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public void unbindService(ServiceConnection serviceConnection) {}
|
public void unbindService(ServiceConnection serviceConnection) {}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user