Reputation: 568
Is it possible?
I mean when I get close some specific place,I get a Notification.
Proximity Alerts will fire a Intent,but I don't know how to start a Notification with a Intent.
Someting like Intent(String action) and IntentFilter?
Upvotes: 1
Views: 1483
Reputation: 49410
Step 1): Set up your proximity alert.
From the LocationManager doc
public void addProximityAlert (double latitude, double longitude,float radius, long expiration, PendingIntent intent)
Define an action and set it in your PendingIntent
.
Step 2): Define in the AndroidManifest.xml
your broadcastreceiver with the same action set in your proximity alert.
In the onReceive
method of the BroadcastReceiver, display your notification
When you will be in the zone that you have define with latitude
, longitude
and radius
,
the PendingIntent
will be fired and will be received and processed by your broadcast receiver.
Upvotes: 1
Reputation: 6447
You have to use a BroadcastReceiver. In the manifest, you can specify the Intents to be filtered by the receiver. In the BroadcastReceiver's "onReceive" method is where you can write the code to show your notification.
Upvotes: 0