Android 如何预防“;计划重新启动崩溃的服务”;?
我发现日志上写着“计划重启崩溃的服务com.qcma.kuo/.keepalive.account.SyncServiceNew,时间为1000ms” 但应用程序(com.qcma.kuo)已经被卸载。我只是想知道发生这种情况的原因是什么?我认为我的代码没有错误。那么有人知道是什么原因造成的吗?有没有办法防止这种情况发生Android 如何预防“;计划重新启动崩溃的服务”;?,android,Android,我发现日志上写着“计划重启崩溃的服务com.qcma.kuo/.keepalive.account.SyncServiceNew,时间为1000ms” 但应用程序(com.qcma.kuo)已经被卸载。我只是想知道发生这种情况的原因是什么?我认为我的代码没有错误。那么有人知道是什么原因造成的吗?有没有办法防止这种情况发生 public class SyncServiceNew extends Service { private static final Object sSyncAdapterL
public class SyncServiceNew extends Service {
private static final Object sSyncAdapterLock = new Object();
private static SyncAdapter sSyncAdapter = null;
@Override
public void onCreate() {
super.onCreate();
startDaemonCoreService();
synchronized (sSyncAdapterLock) {
if (sSyncAdapter == null) {
sSyncAdapter = new SyncAdapter(getApplicationContext(), true);
}
}
}
@Nullable
@Override
public IBinder onBind(Intent intent) {
if (sSyncAdapter == null)
return null;
return sSyncAdapter.getSyncAdapterBinder();
}
private void startDaemonCoreService() {
CoreService.startCoreService(this, null, CoreServiceStartType.TYPE_ACCOUNT_SYNC_START);
}
}
<service
android:name="com.qcma.kuo.keepalive.account.SyncServiceNew"
android:exported="true"
android:process="com.qcma.kuo">
<intent-filter>
<action android:name="android.content.SyncAdapter" />
</intent-filter>
<meta-data
android:name="android.content.SyncAdapter"
android:resource="@xml/syncadapter" />
</service>
公共类SyncServiceNew扩展服务{
私有静态最终对象sSyncAdapterLock=新对象();
专用静态SyncAdapter sSyncAdapter=null;
@凌驾
public void onCreate(){
super.onCreate();
StartDaemOnReserve();
已同步(sSyncAdapterLock){
if(sSyncAdapter==null){
sSyncAdapter=newsyncadapter(getApplicationContext(),true);
}
}
}
@可空
@凌驾
公共IBinder onBind(意向){
if(sSyncAdapter==null)
返回null;
返回sSyncAdapter.getSyncAdapterBinder();
}
私有无效StartDaemOnReserve(){
CoreService.StartReservice(此,空,CoreServiceStartType.TYPE\u ACCOUNT\u SYNC\u START);
}
}