我想知道是否有任何方法可以在一个单独的进程服务被终止(或崩溃)时重新启动,而不将其绑定到应用程序的主进程(我希望该服务即使在应用程序的主进程为由于任何原因被杀死)。
当前,该服务由系统通过AndroidManifest启动:
<service
android:name=".services.MySeparatedProcessService"
android:exported="true"
android:label="SeparatedProcessService"
android:process=":separatedProcess"
android:stopWithTask="false">
<intent-filter>
<action android:name="android.service.notification.MySeparatedProcessService" />
</intent-filter>
</service>
问题在于,当系统启动它时,不调用了以下回调:
public int onStartCommand(Intent intent, int flags, int startId)
所以我无法返回START_STICKY
。
答案 0 :(得分:0)