Wrox Programmer Forums
|
BOOK: Professional Android 4 Application Development
This is the forum to discuss the Wrox book Professional Android 4 Application Development Reto Meier; ISBN: 978-1-1181-0227-5
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Professional Android 4 Application Development section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 14th, 2013, 06:21 AM
Registered User
 
Join Date: Jul 2013
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default WhereAmI project

Hi ,
I'm trying to create GPS alert notification when we the mobile arrive to specific point in 100m radius.
this is my code that deal with, please let me know what i'm doing wrong:

the setProximityAlert methud :

private void setProximityAlert(){

String locService = Context.LOCATION_SERVICE;
LocationManager locationManager;
locationManager = (LocationManager) getSystemService(locService);

double lat = 31.59819563;
double lng = 34.78952749;
float radius = 100f; //meters
long expiration = -1; // never stop

Intent intent = new Intent(TREASURE_PROXIMITY_ALERT);
PendingIntent proximityIntent = PendingIntent.getBroadcast(this, -1, intent, 0);

locationManager.addProximityAlert(lat, lng, radius, expiration, proximityIntent);


}

the ProximityIntentReceiver class :

package com.example.whereami;

import android.app.AlertDialog;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.location.LocationManager;

public class ProximityIntentReceiver extends BroadcastReceiver {

@Override
public void onReceive(Context context, Intent intent) {
String key = LocationManager.KEY_PROXIMITY_ENTERING;

boolean entering = intent.getBooleanExtra(key, false);
if (entering) {
AlertDialog alertDialog = new AlertDialog.Builder(context).create();
alertDialog.setTitle("Pay attention!");
alertDialog.setMessage("You are going to ......");
alertDialog.setCanceledOnTouchOutside(false);
alertDialog.setButton(DialogInterface.BUTTON_POSIT IVE, "YES", new DialogInterface.OnClickListener() {

@Override
public void onClick(DialogInterface arg0, int arg1) {

}
});
alertDialog.setButton(DialogInterface.BUTTON_NEGAT IVE, "NO", new DialogInterface.OnClickListener() {

@Override
public void onClick(DialogInterface arg0, int arg1) {
// TODO Auto-generated method stub

}
});
} else {
AlertDialog alertDialog = new AlertDialog.Builder(context).create();
alertDialog.setTitle("Pay attention!");
alertDialog.setMessage("There is no signal");
alertDialog.setCanceledOnTouchOutside(false);
}

}

}





Similar Threads
Thread Thread Starter Forum Replies Last Post
Chapter 22: Introduction to Project Management... Project Program integration chrisa BOOK: Professional Application Lifecycle Management with Visual Studio 2010 1 September 15th, 2010 03:28 PM
Website project vs Web Application Project... thenoseknows ASP.NET 2.0 Professional 0 January 14th, 2007 09:47 PM
UserControl of One Project in Other Project gadhiav ASP.NET 1.0 and 1.1 Professional 2 February 18th, 2006 07:51 AM
Add report of one project into another project tejaswibv Crystal Reports 0 July 13th, 2005 04:40 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.