Hi,
I have a Service that will run in Background even if the application is
closed. I started the service and I can see it in the "running services"
section under application settings. I am using "*geo fix*" to tell the
emulator location changes. Every time I change the location there is an "OK"
e.g.: geo fix -37.0625 95.67706*OK *but onLocationChanged() is never called.
The same if I tried using DDMS view in eclipse to update location. I checked
the system location preferences and network location is enabled (I only need
network application changes, no GPS). Permissions are set in
AndroidManifest.xml.
I can not figure out why it does not work... here is some code:
public class MyService extends Service {
private static final String TAG = "MyService";
private LocationManager locationMgr;
private LocationListener locListener;
// This method is called
@Override
public void onCreate() {
super.onCreate();
Log.d(TAG, "onCreate");
locationMgr = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
locListener = new LocationListener() {
// ...
// other methods here
// ...
@Override
public void onLocationChanged(Location location) {
// never called
Log.d(TAG, "onLocationChanged");
// some code here...
}
};
locationMgr.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0,
locListener);
}
// This method is called
@Override
public void onStart(Intent intent, int startId) {
super.onStart(intent, startId);
Log.d(TAG, "onStart");
Toast.makeText(getApplicationContext(), "Service started successfully.
Listening in Background for location changes.", Toast.LENGTH_LONG).show();
}
I started the service from an activity:
serviceIntent = new Intent(this, MyService.class);
...
startService(serviceIntent);
Does anybody knows why it does not work? Hope someone can help.
Thank you very much in advance!
-Danny Schimke
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en