borapartha / android-protips-location

Automatically exported from code.google.com/p/android-protips-location
0 stars 0 forks source link

Error in BootReceiver.onReceive - should be getBroadcast not getActivity #12

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
PendingIntent locationListenerPassivePendingIntent = 
PendingIntent.getActivity(context, 0, passiveIntent, 
PendingIntent.FLAG_UPDATE_CURRENT);

should instead read

PendingIntent locationListenerPassivePendingIntent = 
PendingIntent.getBroadcast(context, 0, passiveIntent, 
PendingIntent.FLAG_UPDATE_CURRENT);

as you will discover if you copy this part of the code - the 
PassiveLocationChangedReceiver's onReceive is never called :-)

Original issue reported on code.google.com by ken...@kentonprice.com on 16 Apr 2012 at 4:20

GoogleCodeExporter commented 9 years ago
You can see the correct code used in PlaceActivity.onCreate:

locationListenerPassivePendingIntent = PendingIntent.getBroadcast(this, 0, 
passiveIntent, PendingIntent.FLAG_UPDATE_CURRENT);

Presumably this is the usual happy-case code path. I just had bad luck by 
harvesting the code from the BootReceiver, which presumably wasn't tested as 
thoroughly ;)

Original comment by ken...@kentonprice.com on 16 Apr 2012 at 4:25