【发布时间】:2014-01-23 17:54:05
【问题描述】:
有一个 IntentService 用于每 10 秒更新一次位置。
mIntentService = new Intent(mActivity.getApplicationContext(), MyService.class);
mPendingIntent = PendingIntent.getService(mActivity.getApplicationContext(), 0,
mIntentService, PendingIntent.FLAG_UPDATE_CURRENT);
mLocationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER,
10*1000, 0, mPendingIntent);
应用程序被杀死时位置更新不会停止,它仍然每 10 秒运行一次。我无法删除 onDestroy() 方法中的位置更新,因为即使我们离开活动,该服务也必须运行。如何在应用被杀时自动取消位置更新服务?
【问题讨论】:
标签: android location intentservice