我使用 Android SDK Location Manager 来获取用户位置。
我正在使用 Pending Intent 请求位置信息。我使用了挂起的意图,因为即使应用程序没有运行,我也需要发送位置信息。
Intent mLocationIntent = new Intent(mContext,
LocationIntentService.class);
mLocationUpdatePendingIntent = PendingIntent.getService(mContext, 1,
mLocationIntent, 0);
mLocationManager.requestLocationUpdates(
LocationManager.GPS_PROVIDER, 0, 0,
mLocationUpdatePendingIntent);
使用上述代码注册后,我将在 LocationIntentService 类的 onHandleIntent 处获取位置信息。
但我没有 onProviderEnabled 或 onProviderDisabled 方法来监听 gps 和网络提供商状态。而且我也不想使用融合的位置 api。
如何通过使用 Pending Intent 请求位置更新来实现这两个目标。或者以任何其他方式注册位置信息以及位置提供者状态。