【发布时间】:2018-07-27 07:57:03
【问题描述】:
我正在开发一个应用程序,我必须实现一个功能,当用户输入具有特定半径的特定范围或位置时,例如在地理围栏中。然后它应该发送通知,该通知也在客户端应用程序而不是 FCM 中。我尝试了多种解决方案,但它不起作用。自 Android O .后台任务限制。如何在没有前景的情况下实现此功能,否则看起来很烦人?请如果有人有任何想法请回复。提前致谢。
客户代码
geofencingClient.addGeofences( geoFencingReq(location!!.latitude,location.longitude,name), geofencePendingIntent)
待定意图 ->
val geofencePendingIntent: PendingIntent by lazy {
val intent = Intent(contextt, GeofenceTransitionsIntentService::class.java)
// We use FLAG_UPDATE_CURRENT so that we get the same pending intent back when calling
// addGeofences() and removeGeofences().
PendingIntent.getService(contextt, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT)
}
我已经更新了我使用的代码,但是当应用程序被杀死时它仍然无法工作。
【问题讨论】:
标签: android intentservice android-geofence android-jobscheduler