addProximityAlert() doesn't fire intent

by Joe77 » Tue, 06 Oct 2009 01:17:56 GMT


Sponsored Links
 i,

I am new to Android development and I am trying to write an App that
uses the addProximityAlert() method. I know my intent / intent-filters
work (as I can manually fire the intent) however I cannot seem to get
addProximityAlert to fire an intent. I've searched on various forums
and read the API docs numerous times however have not been able to
determine what is wrong with my code. Any ideas?

package com.example.gpsprox;


import android.app.Activity;
import android.app.PendingIntent;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.Bundle;
import android.widget.Button;
import android.widget.Toast;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;


public class GpsProx extends Activity implements OnClickListener {

private LocationManager lm;
private Proximity prox;
String phoneNo;
String message;
double latitude;
double longitude;
float radius;

private static final String PROXIMITY_ALERT =
"com.example.gpsprox.PROXIMITY_ALERT";





/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);



//---use the LocationManager class to obtain GPS locations---
lm = (LocationManager)
getSystemService(Context.LOCATION_SERVICE);





// Use addProximityAlert public method of locationmanager

// Test Latitude / Longitude is at corner of Bute Gardens and
the broadway.

latitude = 51.4935684;
longitude = -0.2223873;
radius = 0;
// Context context;

Intent intent = new Intent(PROXIMITY_ALERT);

PendingIntent pi = PendingIntent.getBroadcast(getApplicationContext
(), 0, intent, 0);



// sendBroadcast(intent);


lm.addProximityAlert(latitude, longitude, radius, -1, pi);

IntentFilter filter = new IntentFilter(PROXIMITY_ALERT);
registerReceiver(new Proximity(), filter);

Button button = (Button)findViewById(R.id.Button);
button.setOnClickListener(this);

Toast.makeText(getBaseContext(),
"Got here!",
Toast.LENGTH_SHORT).show();


}

// Implement the OnClickListener callback
public void onClick(View v) {

// lm.removeProximityAlert(GpsProx.pi);


finish();

}

public class Proximity extends BroadcastReceiver
{






@Override
public void onReceive(Context context, Intent
intent) {
// TODO Auto-generated method stub


Toast.makeText(getBaseContext(),
"Got her



Other Threads

1. Help magic ga bisa diroot?

Suhu,

Saya dah coba root biasa dan goldcard tp gagal.  Pake root biasa "main version 
is older! update fail!"
Pake goldcard juga sama aja.  Kenapa ya?  
Berikut data HHnya
sapphire PVT 32A Ship S-On H
HBOOT-1.76.0007 (SAPP10000)
CLPD-12
Radio-6.35.07.29

Mohon petunjuk

-- 
"Indonesian Android Community [id-android]" 

2. Google image search diperbaharui

As my siggy :)

@lutfihidayatr
im not a google defender but i always love google innovation




As you maybe un-notice, Google baru memperbaharui google image searchnya
untuk android dan iphone.

Misalkan saya  masukkan info "google boss" di google search panel.
Kemudian saya pilih image.
Keluar gambar2 related dengan pencarian tersebut. (Gbr1)

Klik option dan pilih face, maka pencarian di filter hanya gambar muka
saja.(gbr2)

Klik salah satu image mukanya, dan sekarang tinggal swipe kiri kanan untuk
memunculkan masing2 gambar. (Gbr3)
Lebih mudah dan keren daripada sebelumnya.

Enjoy google inovation

Salam,

Lucky Sebastian

-- 
"Indonesian Android Community [id-android]"

3. (WTI) promo gt+mega diskon 500 rb+cicilan 0% 12 bln for Spica

4. How to custom option menu to arrange three menu items where 2 menu items are displayed at the top and the third below it.

5. <WTA> About sms...!

6. xl brmslah?

7. progress bar in a tabhost