2

We are working on an android app project that invokes an Activity directly at different point of interest (we know its not advicable), even when the app is not running. We've done something but the specified Activity is not invoked at the specified POI. any help..this is the code for two POIs.

import android.location.LocationListener;
import android.location.LocationManager;
import android.location.Location;
import android.os.Bundle;
import android.os.Handler;
import android.os.IBinder;
import android.app.Activity;
import android.app.PendingIntent;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
import android.content.pm.ActivityInfo;
import android.view.Menu;
import android.view.Window;
import android.app.Activity;
import android.view.Menu;

public class MainActivity extends Activity {

    LocationManager lm;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);


        lm = (LocationManager)getSystemService(Context.LOCATION_SERVICE);




        PendingIntent pendingIntent1 = PendingIntent.getActivity(this,0, new Intent (this, SecondActivity.class),0);
        PendingIntent pendingIntent2 = PendingIntent.getActivity(this,0, new Intent (this, ThirdActivity.class),0);


         lm.addProximityAlert(3.867247, 11.496267, 20, -1, pendingIntent1); 
        lm.addProximityAlert(3.8626208, 11.495961, 20, -1, pendingIntent2);  
    }



}
Gagravarr
  • 47,320
  • 10
  • 111
  • 156
  • Can you post output of your logcat? – ACengiz Feb 05 '14 at 07:46
  • ok thanks for answering @ACengiz here's just part of the logcat..hope it helps you to help me :) '02-05 13:16:58.673: I/ProgramMonitor(3640): cpu_usage_wan 02-05 13:16:59.306: I/StatusBarPolicy(1561): BAT. S:2 H:2 ' – Alain Nteff Feb 05 '14 at 12:15
  • Logcat output is not enough for me to comment about problem. There is not error messages here. – ACengiz Feb 05 '14 at 15:41
  • ok @ACengiz ..this is part of what i got for error logcat '02-05 17:45:42.388: E/GlsClient-query(1568): at com.google.common.async.AsyncHttpRequestFactory.run(Unknown Source) 02-05 17:45:42.388: E/GlsClient-query(1568): at com.google.common.lang.BaseThreadFactory$ThreadImpl.run(Unknown Source) 02-05 17:45:42.638: E/PlayEventLogger(2437): Upload failed class java.net.UnknownHostException(play.googleapis.com) 02-05 17:45:44.044: E/SensorManager(2186): unregisterListener:: all sensors, listener = com.twtdigital.zoemob.api.dataAcquirer.a@4076dca8 ' – Alain Nteff Feb 05 '14 at 16:47
  • Hi Alain I'm sorry for my late reply but I haven't found a specific answer yet. The reason may be your applications permissions in your manifest file or a problem about unregistering sensors. – ACengiz Feb 05 '14 at 20:20

1 Answers1

0

Try to register for location updates before you add proximity alert:

lm.requestLocationUpdates(...)

Also make sure you have enabled the location permission on you AndroidManifest.xml file:

<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
Or B
  • 1,675
  • 5
  • 20
  • 41