Unable to display notification when entering GeoFence in Android

佐手、 提交于 2019-12-04 10:02:57

Just check it sample code. u r taking Geo-fencing but you are not mention location client and location connect so that google play service not connect to client and you are not able to receive notification take google requester file and check main acitvity where geofence add in list and also connect location client hope so its work for you

So from the comments you are saying that you are able to add a geofence but you are not getting a notification. Firstly it looks as if you have used the android's geofence sample code which is their on their website and you have changed it so it uses a receiver instead of a service. For me i did the same and this might not seem like the right solution my answer is :

1.) Follow the same steps/code in the google'e geofence : http://developer.android.com/training/location/geofencing.html

2.) since you are changing the service to a receiver , in your createRequestPendingIntent() method are you returning the right broadcast intent ? I mean you have this line but is it reaching there ? is something getting returned there ?

return PendingIntent.getBroadcast( mActivity,0,intent, PendingIntent.FLAG_UPDATE_CURRENT);

3.)Do you have a LocalBroadcastManager.getInstance(this).registerReceiver(mBroadcastReceiver, mIntentFilter); in your onResume() ?

I would follow the google's sample project again and just make sure you are changing the service to receiver part right and you should be fine.

I had the same problem. I think that's because you are using the application context for your pending intent, try to use the activity instead.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!