是否有其他方法可以运行服务来接收位置更新?
答案 0 :(得分:5)
您可以像这样使用PendingIntent -
Intent intent = new Intent(CUSTOM_INTENT);
LocationManager manager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);
PendingIntent launchIntent = PendingIntent.getBroadcast(context, 5000, intent, 0);
manager.requestLocationUpdates(selectProvider(), 0, 0, launchIntent);
您的广播接收器应该具有清单文件中CUSTOM_INTENT的意图过滤器