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. Can we customize status bar height?

Is it possible to change the height of the status bar?  We need to
maximize our use of the existing screen real estate for our
application content, but can't just hide the status bar.

Thanks!
Cheryl
--~--~---------~--~----~------------~-------~--~----~

2. Unknown URL content://contacts

Hi

When I run the following lines in my code, I get the error
java.lang.IllegalArgumentException:  Unknown URL content://contacts



String[] PEOPLE_PROJECTION = new String[] {
                        Contacts.People._ID,
                        Contacts.People.NAME,
                        Contacts.People.NUMBER_KEY
                        };
____________________________________________________________

        Cursor cursor = managedQuery(Contacts.CONTENT_URI,
            PEOPLE_PROJECTION, null, null,
Contacts.People.DEFAULT_SORT_ORDER);
    int name = cursor.getColumnIndex(Contacts.People.NAME);



Kindly help.
--~--~---------~--~----~------------~-------~--~----~

3. How does "deleteRow" work in a Cursor object

4. Turning on single column layout mode?

5. Is this an Android-capable device?

6. Vista sound prob

7. changingcolor on TextView