1

i have used broadcast reciever for getting alerts on specific location using pending intents(proximate alerts) but it do not fire any notification when app is closed or in background how i can do this please help me to set this .
here what i tried in xml:

<receiver android:name=".ProximityIntentReceiver">
      <intent-filter>
    <action android:name="android.intent.action.BOOT_COMPLETED"/>
    </intent-filter>
    </receiver>

i also register it in activity :

IntentFilter filter = new IntentFilter(PROXIMTY_ALERT_INTENT);  
         registerReceiver(new ProximityIntentReceiver(), filter);

in this way im getting notification when activity is running but afert i closed it i do not get any notification. what is proper way to do this.

Bibi Tahira
  • 1,082
  • 5
  • 15
  • 39

2 Answers2

0

I haven't found any documentation regarding PROXIMTY_ALERT_INTENT. Some broadcasts can't be registered from manifest.xml. If this is one of them you can receive those updates only during the application lifetime.

The receiver you defined for BOOT_COMPLETED needs the following permission to work:

<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"></uses-permission>

You can start a service in the receiver for BOOT_COMPLETED intent and register there for the proximity alert. Usually having a service running all the time is not recommended and you might want to think for another approach.

azertiti
  • 3,150
  • 17
  • 19
0

You could add more actions to your intent filter, this question here should help you with that: BroadcastReceiver for location

Or there may be a way of creating a Listener to listen for changes in GPS location. Check here for information: http://developer.android.com/reference/android/location/LocationListener.html

Community
  • 1
  • 1
Matt Harris
  • 3,496
  • 5
  • 32
  • 43