1. Are you ready for the Galaxy S20? Here is everything we know so far!

MapLocation Manager Illegal state exception, System services service not available

Discussion in 'Android Development' started by dush, Sep 2, 2011.

  1. dush

    dush Lurker
    Thread Starter

    Hi All,

    I am trying to develop a MAP Application using GPS to get the locational lat , lon details.
    However,
    as soon as i use location manager i get a FATAL Exception caused by illegal state exception System Service not available

    Please suggest


    LocationManager locationManager = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE);


    Exception trace:

    09-01 14:27:49.179: ERROR/AndroidRuntime(604): FATAL EXCEPTION: main
    09-01 14:27:49.179: ERROR/AndroidRuntime(604): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.android.map/com.android.map.HelloMapActivity}: java.lang.IllegalStateException: System services not available to Activities before onCreate()
    09-01 14:27:49.179: ERROR/AndroidRuntime(604): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1569)
    09-01 14:27:49.179: ERROR/AndroidRuntime(604): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
    09-01 14:27:49.179: ERROR/AndroidRuntime(604): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
    09-01 14:27:49.179: ERROR/AndroidRuntime(604): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
    09-01 14:27:49.179: ERROR/AndroidRuntime(604): at android.os.Handler.dispatchMessage(Handler.java:99)
    09-01 14:27:49.179: ERROR/AndroidRuntime(604): at android.os.Looper.loop(Looper.java:130)
    09-01 14:27:49.179: ERROR/AndroidRuntime(604): at android.app.ActivityThread.main(ActivityThread.java:3683)
    09-01 14:27:49.179: ERROR/AndroidRuntime(604): at java.lang.reflect.Method.invokeNative(Native Method)
    09-01 14:27:49.179: ERROR/AndroidRuntime(604): at java.lang.reflect.Method.invoke(Method.java:507)
    09-01 14:27:49.179: ERROR/AndroidRuntime(604): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
    09-01 14:27:49.179: ERROR/AndroidRuntime(604): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
    09-01 14:27:49.179: ERROR/AndroidRuntime(604): at dalvik.system.NativeStart.main(Native Method)
    09-01 14:27:49.179: ERROR/AndroidRuntime(604): Caused by: java.lang.IllegalStateException: System services not available to Activities before onCreate()
    09-01 14:27:49.179: ERROR/AndroidRuntime(604): at android.app.Activity.getSystemService(Activity.java:3536)
    09-01 14:27:49.179: ERROR/AndroidRuntime(604): at com.android.map.HelloMapActivity.<init>(HelloMapActivity.java:23)
    09-01 14:27:49.179: ERROR/AndroidRuntime(604): at java.lang.Class.newInstanceImpl(Native Method)
    09-01 14:27:49.179: ERROR/AndroidRuntime(604): at java.lang.Class.newInstance(Class.java:1409)
    09-01 14:27:49.179: ERROR/AndroidRuntime(604): at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
    09-01 14:27:49.179: ERROR/AndroidRuntime(604): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1561)
    09-01 14:27:49.179: ERROR/AndroidRuntime(604): ... 11 more
    09-01 14:27:49.189: WARN/ActivityManager(61): Force finishing activity com.android.map/.HelloMapActivity
    09-01 14:27:49.709: WARN/ActivityManager(61): Activity pause timeout for HistoryRecord{4052d730 com.android.map/.HelloMapActivity}
     



    1. Download the Forums for Android™ app!


      Download

       
  2. jonbonazza

    jonbonazza Android Expert

    Did you put that command before the onCreate() method?
     
Loading...

Share This Page

Loading...