我的Android服务在某些设备上正常运行。在其他设备上,它显示在“正在运行的应用程序”中运行,但它不起作用,它占用0 MB RAM。我也试过这个解决方案。
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
IntentFilter screenStateFilter = new IntentFilter();
screenStateFilter.addAction(Intent.ACTION_TIME_TICK);
//Toast.makeText(getApplicationContext(),"start",Toast.LENGTH_LONG).show();
registerReceiver(timeTickReceiver, screenStateFilter);
super.onStartCommand(intent, flags, startId);
//return super.onStartCommand(intent, flags, startId);
return Service.START_REDELIVER_INTENT;
}
请告诉我如何解决这个问题
答案 0 :(得分:0)
public int onStartCommand(Intent intent, int flags, int startId) {
IntentFilter screenStateFilter = new IntentFilter();
screenStateFilter.addAction(Intent.ACTION_TIME_TICK);
//Toast.makeText(getApplicationContext(),"start",Toast.LENGTH_LONG).show();
registerReceiver(timeTickReceiver, screenStateFilter);
// try removing this line commented below
// super.onStartCommand(intent, flags, startId);
//return super.onStartCommand(intent, flags, startId);
return Service.START_REDELIVER_INTENT;
}
检查我的评论