我的 android 应用程序中有一个服务,只有在退出应用程序时才会停止。
public class MyService extends Service {
public MyService() {
}
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
try {
if(intent != null){
//......
}
} catch (Throwable e) {
}
return START_STICKY;
}
@Override
public void onDestroy() {
super.onDestroy();
}
@Override
public void onCreate() {
super.onCreate();
//......
}
@Override
public IBinder onBind(Intent intent) {
return null;
}
}
该服务有时会在运行时调用它的 onCreate() 方法。当检查它正在运行的服务状态时,但它的功能不起作用。我被困在这个上面好几个小时了。这里有什么问题?我试过 onLowMemory()这项服务。但不是结果。