Retrieving the location provider "gps" causes a NullPointerException in LocationManager.createProvider

by NTR » Mon, 07 Apr 2008 00:35:49 GMT


Sponsored Links
 When I try using the "gps" provider, I get the following:

ERROR/AndroidRuntime(3253): Caused by: java.lang.NullPointerException
ERROR/AndroidRuntime(3253):     at
android.location.LocationManager.createProvider(LocationManager.java:
61)
ERROR/AndroidRuntime(3253):     at
android.location.LocationManager.getProvider(LocationManager.java:119)
ERROR/AndroidRuntime(3253):     at
net.lbns.mobileclient.util.LocationUtil.getLocationProvider(LocationUtil.java:
21)

Code:

public static LocationProvider getLocationProvider(Application app) {
    try {
      LocationManager locationManager = getLocationManager(app);
      return locationManager.getProvider("gps");
    }
    catch (SecurityException e) {
      return null;
    }
  }

  public static LocationManager getLocationManager(Application app) {
    return (LocationManager)
app.getSystemService(Context.LOCATION_SERVICE);
  }

The application is retrieved by using getApplication() of a sub-
activity. Any help?
--~--~---------~--~----~------------~-------~--~----~



Other Threads

1. android.R.drawable.ic_menu_home - can not use

It's intentional.



> 

2. Scheduling question

Hello.

I was just asked by my professor "Which scheduling algorithm is used
in the Android OS"?

We were having a discussion about RMA/DMA vs EDF.

Can you guys help me out?

Thanks in advance,

Haris

-- 
unsubscribe: android-kernel+unsubscr...@googlegroups.com
website: 

3. Do I need to notify users that I'm using analytics in my Android app? (like Flurry, Admob analytics or even logging tool like DriodDrop)

4. How to extract the .properties files in a third party jar file to apk file

5. Can i create file dir when apk installing on device

6. KeyEvent in View Extended Class

7. Launching Android's default PhoneLocker Application