I'm creating a project that allows for my location to be found using
the android device and communicating with my website as to where my
Android device is. When I download the .apk to my phone the following
permissions are acquired:
Network communication (full)
Your location (fine (GPS), coarse (network-based) location)
As of now, on the emulator everything works fine and I can find my
location (default location on Google Maps), but on the phone the
application/device can't find location of the android phone.
please help!...below is the code I'm using for the GPS section.
- Amir
----
package org.gw.service;
import android.content.Context;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.Bundle;
import android.widget.Toast;
public class LocationService extends AService {
public int excute() {
getDataMap().put(Command, LOCATION);
if (isOk()) {
// // location.
// getDataMap().put(Des, "OK");
// //get location
// getDataMap().put(Value, "100,100");
// String location = "25,121.55";
LocationManager lm = (LocationManager) getContext()
.getSystemService(Context.LOCATION_SERVICE);
LocationListener locationListener = new GWLocationListener(this);
lm.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0,
locationListener);
} else {
getDataMap().put(Des, "error password!!");
}
return 0;
}
private class GWLocationListener implements LocationListener {
private LocationService service;
public GWLocationListener(LocationService service) {
this.service=service;
}
@Override
public void onLocationChanged(Location loc) {
if (loc != null) {
String location = loc.getLatitude()+","+loc.getLongitude();
service.getDataMap().put(Value, location);
getDataMap().put(Des, "OK");
new ServiceClient(service).excute();
}
else
{
getDataMap().put(Des, "Location fail!");
new ServiceClient(service).excute();
}
}
@Override
public void onProviderDisabled(String provider) {
return;
}
@Override
public void onProviderEnabled(String provider) {
return;
}
@Override
public void onStatusChanged(String provider, int status, Bundle
extras) {
return;
}
}
}
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---