I am developing an application that wakeup to you when you reach/near your destination and send you notification like Alarm.
Is it any way whether i check continuously user's current location and when user is near/reach destination?
If it is possible than please give me sample/tutorial so that i can implement it easily.
Till now,i implement below code that indicates "Notification".
public class ProximityReceiver extends BroadcastReceiver {
private static final int ALARM_DURATION = 6000;
public static final String INTENT_NAME = "com.xxx.xxx.intent.PROXIMITY";
private static final long VIBRATION_PATTERN[];
static {
long al[] = new long[6];
al[1] = 1000L;
al[2] = 500L;
al[3] = 1000L;
al[4] = 500L;
al[5] = 1000L;
VIBRATION_PATTERN = al;
}
@Override
public void onReceive(Context context, Intent intent) {
MyMainApplication wakeappapplication = (MyMainApplication) context
.getApplicationContext();
if (wakeappapplication.getStatus().equals(WakeAppStatus.STARTED)) {
wakeappapplication.setStatus(WakeAppStatus.APPROACHING);
long l = 6000L + System.currentTimeMillis();
((AlarmManager) context.getSystemService("alarm")).setRepeating(0,
l, 6000L, wakeappapplication.getProximityPendingIntent());
}
NotificationManager notificationmanager = (NotificationManager) context
.getSystemService("notification");
notificationmanager.cancel("ProximityReceiver", 0);
Notification notification = new Notification(
R.drawable.ic_stat_notify_wakeapp,
context.getString(R.string.text_wake_title),
System.currentTimeMillis());
PendingIntent pendingintent = PendingIntent.getActivity(context, 0,
new Intent(context, MainWakeMeUpActivity.class), 0);
notification.setLatestEventInfo(context,
context.getString(R.string.text_wake_title),
context.getString(R.string.text_wake_descr), pendingintent);
android.net.Uri uri = wakeappapplication.getChosenRingtone();
if (uri != null)
notification.sound = uri;
notification.vibrate = VIBRATION_PATTERN;
if (wakeappapplication.isRaiseVolume())
((AudioManager) context.getSystemService("audio")).adjustVolume(1,
0);
notificationmanager.notify("ProximityReceiver", 0, notification);
}}