I have yet to test this on a real phone.
My problem is this service is supposed to send output to a log, when
the location is changed.
It isn't working, I don't know why. AndroidManifest has permission for
fine, coarse, and mock locations.
I sent locations using (telnet localhost (port), geo fix 12.2321
12.23232) etc AND via eclipse controls.
The service runs the whole time, but the log never receives info from
the onLocationChanged command, but it DOES receive info from onStart,
onCreate, startUpdates, etc.
My service is started via:
Intent myLocService = new Intent(this, FmiLocationManager.class);
startService(myLocService);
-------------------------
Service:
package org.findmydroid;
import android.content.Context;
import android.content.Intent;
import android.app.Service;
import android.location.LocationManager;
import android.location.Location;
import android.location.LocationListener;
import android.os.Bundle;
import android.os.IBinder;
import android.util.Log;
import android.location.Criteria;
public class FmiLocationManager extends Service implements
LocationListener
{
private LocationManager locationMan;
private LocationListener locationLis;
public void onCreate()
{
Log.e("fmi","fmi fmilocationmanager created");
}
public void onStart()
{
startUpdates();
Log.e("fmi","fmi fmilocationmanager started and updates
started");
}
public void onStop()
{
stopUpdates();
Log.e("fmi","fmi location updates stopped");
}
public void startUpdates()
{
Log.e("fmi","fmi startUpdates in locationmanager called");
locationMan = (LocationManager) getSystemService
(Context.LOCATION_SERVICE);
if (locationMan == null)
Log.e("fmi","fmi locationManager is null, bad
context?");
String provider;
if(locationMan.isProviderEnabled(LocationManager.GPS_PROVIDER))
provider = LocationManager.GPS_PROVIDER;
else
{
Criteria bestCrit = new Criteria();
bestCrit.setAccuracy(Criteria.ACCURACY_FINE);
bestCrit.setAltitudeRequired(false);
bestCrit.setCostAllowed(false);
bestCrit.setSpeedRequired(false);
bestCrit.setBearingRequired(false);
provider = locationMan.getBestProvider(bestCrit,true);
}
locationMan.requestLocationUpdates(
provider,
12000,
1,
this);
}
public void stopUpdates()
{
if(locationLis != null)
locationMan.removeUpdates(locationLis);
}
@Override
public IBinder onBind(Intent intent) {
return null;
}
public void onLocationChanged(Location loc) {
Log.e("fmi","fmi new location received");
/////////////////////////////?THIS IS WHAT ISN'T EVER
CALLED////////////////////
}
}
}
public void onProviderDisabled(String provider) {
}
public void onProviderEnabled(String provider) {
}
public void onStatusChanged(String provider, int status,
Bundle extras) {
}
}
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---