我正在使用Intent Service来监控Geofence过渡.为此,我正在使用Sticky Service的跟随电话.
LocationServices.GeofencingApi.addGeofences(
mGoogleApiClient,
getGeofencingRequest(),
getGeofencePendingIntent()
)
Run Code Online (Sandbox Code Playgroud)
Pending Intent调用Transition Service(IntentService),如下所示.
private PendingIntent getGeofencePendingIntent() {
Intent intent = new Intent(this, GeofenceTransitionsIntentService.class);
// We use FLAG_UPDATE_CURRENT so that we get the
//same pending intent back when calling addgeoFences()
return PendingIntent.getService(this, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
}
Run Code Online (Sandbox Code Playgroud)
这工作很好Pre Oreo.但是,我必须将我的粘性服务转换为JobScheduler,我需要将GeofenceTransitionsIntentService哪个是intentService 转换为JobIntentService.
说过我不知道如何返回为JobIntentService创建一个PendingIntent,因为我需要为JobIntentService调用enqueueWork.
任何建议/指针将不胜感激.
android android-geofence android-service-binding android-8.0-oreo