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. Jac HeroOOT : Belajar Root Android

@oom Duliar:JacHero versi berapakah?
Testinya dong..mo coba nih.dari kemaren gak jadi2 euy
Nguprek CyanMod tyus wkwkwk

@nukudroid
thenukudroid.wordpress.com

Sent from my HTC Dream Gstring




Hallo kawans...

sorry, semalam begadang wkwk...coba2 praktekin saran2 dari Para Suhu
Master disini.. :)

Hasilnya, belum tau ini benar atau nggak, tapi saat ini lg pake rom
nya Hero punya JacHero..
setelah nyoba urutan2 dari Unlockr..

berasa hero banget sih, di bandingkan langsung dengan Hero yang
rencana besok mau berangkat ke Banten..
tapi untuk animasi weather belum dapat.. *penasaran.com*

Jadi pengen ikutan kopi darat nih.. biar mantap..

Mohon pencerahannya.. atau kalo perlu ganti topic.. yang ini kita
close aja yuuk..

thanks everyone...








...

-- 
"Indonesian Android Community [id-android]" 

2. Multitasking on Android - Why So Incredibly Bad?

This could be because currently we give an app at most 1/5 second to return
from onSaveInstanceState() + onPause() before going to the next app.  If the
browser is taking longer than that, we will give up and launch the next app,
causing browser to go to the background.  If we are under so much memory
pressure at that point that the browser is immediately killed, then it may
not have actually gotten to the point of giving its saved state to the
system.












> > >> 

3. Black screen when playing a streaming video

4. Multitasking on Android - Why So Incredibly Bad?

5. struct proto in /net/ipv4/tcp_ipv4.c

6. The $50,000 Android Phone

7. Handle GONE in RelativeLayout