Double. I was using Int.
On Nov 2, 11:56 pm, jay mojnidar <jay.mojni...@gmail.com> wrote:
> All,
>
> 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.
>
> Any help is appreciated. Following is my code.
>
> My Manifest file
> <?xml version="1.0" encoding="utf-8"?>
> <manifest xmlns:android="http://schemas.android.com/apk/res/android"
> package="test.android.mapapp"
> android:versionCode="1"
> android:versionName="1.0">
> <application android:icon="@drawable/icon"
> android:label="@string/app_name" android:debuggable="true">
>
> <uses-library android:name="com.google.android.maps" />
>
> <activity android:name=".MapsActivity"
> android:label="@string/app_name">
> <intent-filter>
> <action android:name="android.intent.action.MAIN" />
> <category android:name="android.intent.category.LAUNCHER" />
> </intent-filter>
> </activity>
>
> <*receiver *android:name=".ProximityIntentReceiver">
> <intent-filter>
> <action android:name="android.intent.action.PROXIMITY_ALERT" />
> </intent-filter>
> </receiver>
> </application>
>
> <uses-permission android:name="android.permission.INTERNET" />
> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"
> />
>
> <uses-permission android:name="android.permission.COARSE_FINE_LOCATION"
> />
>
> <uses-sdk android:minSdkVersion="3" />
>
> </manifest>
>
> package test.android.mapapp;
>
> public class MapsActivity extends MapActivity {
>
> MapController mc;
> GeoPoint home = null, school = null, curLoc = null;
> MapOverlay mapOverlay;
> MapView mapView;
> protected static final String PROXIMITY_ALERT = new
> String("android.intent.action.PROXIMITY_ALERT");
> protected final IntentFilter proximitylocationIntentFilter = new
> IntentFilter(PROXIMITY_ALERT);
> Intent intent = new Intent(PROXIMITY_ALERT);
>
> /** Called when the activity is first created. */
> @Override
> public void onCreate(Bundle savedInstanceState) {
> super.onCreate(savedInstanceState);
> setContentView(R.layout.main);
>
> //get the underlying mapView
> mapView = (MapView) findViewById(R.id.mapView);
>
> //set some mapView properties
> mapView.setBuiltInZoomControls(true);
> mapView.displayZoomControls(true);
> //set home address
> setHomeAddress(mapView);
>
> //now play with the location
> LocationManager lm = (LocationManager)
> getSystemService(Context.LOCATION_SERVICE);
>
> //Send current location messages to the listener every second.
> CurrentLocationListener listener = new CurrentLocationListener();
> lm.requestLocationUpdates(LocationManager.GPS_PROVIDER, 1000, 1,
> listener);
>
> //Get a message when we get near home...
> PendingIntent proximityIntent =
> PendingIntent.getBroadcast(getApplicationContext(),0, intent, 0);
> lm.addProximityAlert(home.getLatitudeE6(), home.getLongitudeE6(),
> 50, 1000000, proximityIntent);
>
> * //the returned value "check" is always null.* I know the new object
> ProxmityIntentReceiver object is being created.
> Intent check = registerReceiver(new ProximityIntentReceiver(),
> proximitylocationIntentFilter);
> }
>
> @Override
> protected boolean isRouteDisplayed() {
> return false;
> }
>
> public void setHomeAddress(MapView mapView)
> {
> //snip set the home address co-ordinates and call MapOverlay to
> display
>
> }
>
> private class CurrentLocationListener implements LocationListener
> {
>
> public void onLocationChanged(Location location) {
>
> //get the current location and display that in the map.
> curLoc = new GeoPoint(
> (int) (location.getLatitude() * 1E6),
> (int) (location.getLongitude() * 1E6));
>
> mc.animateTo(curLoc);
> //---Add a location marker---
> mapOverlay = new MapOverlay(curLoc);
> List<Overlay> listOfOverlays = mapView.getOverlays();
> listOfOverlays.clear();
> listOfOverlays.add(mapOverlay);
> mapView.invalidate();
> }
> //snip other overridden methods
> }
>
> } //end of MapsActivity cla
>
> Below is the code to recieve the proximity message which never gets called.
>
> package test.android.mapapp;
>
> public class ProximityIntentReceiver extends BroadcastReceiver {
>
> @Override
> public void onReceive (Context context, Intent intent) {
>
> Log.i("ProximityReceiver","Here in onRecieve");
>
> }
>
> }
>
>
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
No comments:
Post a Comment