我正在尝试在单独的进程中启动服务,以便即使在用户关闭应用程序之后它也会运行。
我谷歌,并找到了一些解决方案。我采用了以下方法,但它崩溃了服务。
我在Manifest
文件中添加了以下内容
<service android:name=".myservices.services.LocationUpdateService"
android:process=":locationservice"
android:isolatedProcess="true"
/>
如果我删除最后两行,它会成功启动服务,但是将它停在onDestroy of application上。
这就是我开始服务的方式。
Intent intent= new Intent(MainActivity.this, LocationUpdateService.class);
startService(intent);
请指导我在单独的过程中启动它需要做的其他步骤。