Android :: Need Tutorial On Usage Of GPS Proximity Alerts With PendingIntent
Aug 5, 2009Can anyone post some sample code or point me to a tutorial on usage of GPS proximity alerts with PendingIntent?

Can anyone post some sample code or point me to a tutorial on usage of GPS proximity alerts with PendingIntent?
SDK: 1.6 Firmware Version: 1.5
I am trying to get an alert when I get to my home. But, it looks like I am not receiving the message. Googled around quite a bit, but to no avail. I am able to get the LocationListener to display my current location. But, proximityAlerts are not working. The problem might be with the setting up and receiving the broadcast messages.
Following is my code...
I'm trying to configure proximity alerts that will be feed from a Database and webservice provider; but I have a problem configuring a simple proximity alert for testing. I manage to create the alert but it never gets fired, I'm only trying in the emulator for now and donīt know if I need some extra code to trigger the alerts. I've read somewhere that the GPS provider to disabled so the network provider can be used in order to trigger the alerts on the emulator.
My code looks like this:...................
I am wondering how you would cancel a notification when you are not the party executing the associated Intent.For example, think about an Intent like ACTION_VIEW and a data/url like http://google.com. This intent is then wrapped into a PendingNotification and used by a notification. So when the user clicks on the notification the intent is fired, the browser opens, but the notification is not cancelled. As my code is not the receiver of the Intent how should I cancel it?
View 3 Replies View RelatedI used AlarmManager to set the pending intent.
I need to find out the state of the pending intent, in other word, is this pending intent working or not. Boz i may need to cancel this pending intent, but before canceling it i want to make sure it's active.
But i see no function in AlarmManager can read this status.
you can subscribe to requestLocationUpdates via two ways one by specifing a PendingIntent the other is by using a LocationListener. When is advised the one and when the other?
View 1 Replies View RelatedIs is possible to get back a result intent when launching an Intent from a Notification? Similar to the way startActivityForResult() works ?
View 3 Replies View RelatedI set an PendingIntent on a Notification (notification.setLatestEventInfo). this intent is actually the same intent used to launch my app, only with a flag that I put in the extra (intent.putExtra(TAB_INDEX_PARAM_NAME, UPDATES_TAB_INDEX)).
So my first activity launches, it queries it's intent's extras and immediately navigates to an Alerts activity rather the normal activity on a regular launch.
The problem: from this point, every activation of my app navigates to this Alerts activity. when debugged, I find that the flag is "stuck" in the intent even though I removed/changed it. it just won't change.
How can change an extra on a giving Intent?
My app consists of an Activity and a service that runs in the background. The service periodically checks a website for an alarm condition. When the service detects the alarm, it should put a user notification into the status bar. If the user clicks the notification, it should display the app's activity. If the activity is already running, that activity should become visible. If the activity is not currently running, it should be created.
However the notification created by my service *always* creates a new instance of the activity, whether the activity is currently running or not. How do I get the desirable behavior?
Here is my service pseudo-code:
CODE:...............
I'm creating a notification with something similar to the following:
CODE:............
The key here is the extra data on the Intent for the notification. Once I click on the notification and it brings up SomeActivity, it brings up the activity and the extra data is available.
However, if I exit the app, hold the home button until the recent activities list comes up, and choose to open the app again, the extra data is still passed. Is there a way I can make this data get passed only if the app is opened via the Notification, and not from the recent activities list?
I am adding some basic alarm functionality to my program via the use of AlarmManager and a BroadcastReceiver class (named AReceiver.java). My problem is that the data I add to the bundle attached to the Intent creating the PendingIntent appears to be lost. The only bundle data I can access in the AReceiver class is a android.intent.extra.ALARM_COUNT=1. Here is the basic code in the main activity class creating the Intent, PendingIntent and the AlarmManager: [Code in main activity - Notepadv3]
Intent intent = new Intent(Notepadv3.this, AReceiver.class);
intent.putExtra("teststring","hello, passed string in Extra");
PendingIntent alarmIntent = PendingIntent.getBroadcast(this, pendingPeriodIntentId, intent, 0);
AlarmManager am = (AlarmManager) getSystemService(ALARM_SERVICE);
am.set(AlarmManager.RTC_WAKEUP, timeOfNextPeriod.getTimeInMillis(), alarmIntent);..................
This questions somehow relates to the question when I was looking to get the extras back in startActivityForResult but now I face another challenge.
I have subscribed to receive ProximityAlerts and I have explicitly constructed the Intent to include some Extras. But when I got the service the extras are not there.
After the answers here is the working code:
CODE:..........................
The documentation says param PendingIntent to be sent for each location update.
I don't know if it's my phone or what but when I look up the Other Usage on my phone, it shows it "Running" more than 2/3 of the time.And on Network Usage, "Android System" and "Media" use a great deal of the phone as well.I think this might have to do with my "android.process.acore" crashing every once in a while when it's asleep. Based on everyone's feedback I might have to return the Moment for a third time.
View 1 Replies View RelatedIs there an app that will automatically trigger the loudspeaker when the phone isn't next to my head? Then revert to normal once the proximity sensor sees it's at my ear again?
View 7 Replies View RelatedI wrote a simple app that uses proximity alerts and after installing it on my G1 found that battery life have been halved at least. It's so bad that phone needs to be recharged mid-day or it completely dies by 9pm. There is no polling of any kind - just proximity alerts (3 of them). I tried with GPS turned off (using network triangulation for coarse GPS location) but battery life is still abysmal. Is there a general solution to improve battery life with proximity alerts or the whole GPS thing is a non-starter on G1s?
View 5 Replies View RelatedI am adding a proximity Alert with an expiration of -1 (does not expire). I am testing using an Evo. The proximity Alert fires several times after entering the location and staying inside the location. I was thinking that the proximity alert should fire once when you enter the location and fire once when you exit the location. Should the proximity alert fire multiple times after you enter the location and stay inside of the location?
View 2 Replies View RelatedI have an application that needs to turn on/off the screen using the proximity sensor like what most dialer applications do when a user is making a phone call. I cannot seem to find a way to turn on/off the screen at will.
View 2 Replies View RelatedI am trying to register to several proximity alerts. Here's an excerpt:................
View 3 Replies View RelatedI am trying to determine if an Android user has had a close proximity to a list of predetermined locations. I'd like to do this with the least amount of drain on the phone's battery. The two mechanisms I see for accomplishing this are proximity alerts and requesting location updates. What are the pros and cons of the two methods? Will one have less affect on the battery than the other? In either case I would guess the specific location manager used would have some affect power usage (existing Stack Overflow answer).
View 1 Replies View RelatedWhere abouts is the sensor that detects if you are holding the phone up to your ear and dims the screen? Need to modify my wife's case (like what I did with her old iPhone case) as it doesnt turn the screen off, or if it does it doesnt turn it back on afterwards!
View 3 Replies View RelatedWhy do we have a proximity sensor? Coming from Nokia phone, I not only don't understand it I don't like it.Can it be removed - disabled? How?
View 9 Replies View RelatedI'm on Mac OS X Leopard and installed the ADT plugin into Eclipse Galileo. I followed all these steps to get started:
http://developer.android.com/sdk/index.html
My SDK version is 2.2 API 8 revision 2 and I just used the Hello World tutorial found here:
[url]
When I first created the Android application, I saw this error in the Eclipse console:
[2010-11-13 18:20:43 - HelloAndroid] ERROR: Unable to open class file / Users/mydirectory/Documents/workspace/HelloAndroid/gen/com/example/ helloandroid/R.java: No such file or directory
I commented out this line to fill in the few lines from the tutorial:
setContentView(R.layout.main);
When I ran the app, it launched my emulator but all I saw was a vertical screen on the left that said "ANDROID" and phone buttons on the right. I did not see the "Hello, Android" text from the tutorial.
I need to display contents of a list of objects. Capture the selected items and later process it. I have been trying to find a tutorial on net but in vain. Could some one please advise me when can I find a tutorial. I know how to display a list but I want the CheckedTextView option.
View 4 Replies View RelatedI was working through the Notepad tutorial... http://developer.android.com/guide/tutorials/notepad/index.html ...and I seem to either have a misunderstanding of what is supposed to be happening, or the code is not working.
Below are two snippets of code from the tutorial to illustrate my questions/concerns:
It looks like this is the "menu" that is brought up when you have no items selected and you press the Menu key...
CODE:...........
This is the behavior that I expected and saw.
However, when I have one of the notes selected, I would expect this code snippet to run...
CODE:.............
But it doesn't. I can never get the "delete" option to show up in the tutorial.
I've never used bettercut and am after a tutorial. I have this homescreen. want to change the GMail icon to the same green as everything else.
View 8 Replies View RelatedAndroid has a limit to rum at MAX 20 concurrent AsyncTask. To handle this limit I created a AsyncTaskPool.java utility. Its not a pool in true sense but a kind of scheduler.
CODE:..................
I'm on Mac OS X Leopard and installed the ADT plugin into Eclipse Galileo. I followed all these steps to get started:
http://developer.android.com/sdk/index.html
My SDK version is 2.2 API 8 revision 2 and I just used the Hello World tutorial found here:
[url]
When I first created the Android application, I saw this error in the Eclipse console:
[2010-11-13 18:20:43 - HelloAndroid] ERROR: Unable to open class file / Users/mydirectory/Documents/workspace/HelloAndroid/gen/com/example/ helloandroid/R.java: No such file or directory
I commented out this line to fill in the few lines from the tutorial:
setContentView(R.layout.main);
When I ran the app, it launched my emulator but all I saw was a vertical screen on the left that said "ANDROID" and phone buttons on the right. I did not see the "Hello, Android" text from the tutorial.
Is it even that big of a deal on the Hero, and is the app even useful?
View 10 Replies View RelatedI had real problems until with my phone until I loaded the proximity sensor. I had a little trouble getting it to work but when it did, it remedied the one thing that I disliked about the Hero. I loaded 2.1 yesterday and generally I like it EXCEPT I cannot get the proximity sensor app to work again. Has any one else had this issue? Suggestions?
View 14 Replies View RelatedAnyone still having problems with the black screen? Have downloaded and installed the ota update and if anything the problem is worse! Seems ok on incoming calls but if I make an outgoing call the screen goes blank and the only way to reactivate is to hit the power key. This is starting to sound like faulty hardware to me. I read that the ota update was supposed to sort this! Any advise would be appreciated as other than this really annoying problem the phone is great!
View 9 Replies View Related