Hi My app is an Google api map. I would like it to be compatible with old android version sso I have included the android compatibility package jar v4 in the libs folder. In my manifest I have:
I have this service which starts when my app starts and I want it to update the location and then when the map will be loaded it will be faster. So I have this code in the onCreate method of my service:
Criteria criteria = new Criteria();
locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
if (isEmulator() || !isOnline())
provider = LocationManager.GPS_PROVIDER;
else
provider = locationManager.getBestProvider(criteria, false);
try {
Location location = locationManager.getLastKnownLocation(provider);
if(location==null || location.getTime()>(new Date().getTime()-Constants.TIEMPO_ENTRE_LOC_UPDATE))
locationManager.requestSingleUpdate(provider, null);
}catch (Exception e){
e.printStackTrace();
}
the thing is when I launch the app on emulator (google apis level 7) I get this error:
01-02 12:21:30.971: E/AndroidRuntime(523): java.lang.NoSuchMethodError: android.location.LocationManager.requestSingleUpdate
01-02 12:21:30.971: E/AndroidRuntime(523): at com.tresipunt.scm.MyService.onCreate(MyService.java:78)
Well of course I know requestsingleupdate is not available in earlier apis but isn’t the compatibility package supposed to fix it? How could I solve the problem? thks a lot
The compatbility package does not include the LocationManager. You can see available packages here:
http://developer.android.com/sdk/compatibility-library.html#Using