Android:如何以编程方式显示位置源设置



我想打开位置源设置,我这样做

    Intent intent = new Intent( Settings.ACTION_LOCATION_SOURCE_SETTINGS );
    startActivityForResult(intent, 0);

,但在某些手机(主要Android 4.0.4,部分4.1.2),它报告一个异常:

    android.content.ActivityNotFoundException: No Activity found to handle Intent {   act=android.settings.LOCATION_SOURCE_SETTINGS }
at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1518)
at android.app.Instrumentation.execStartActivity(Instrumentation.java:1390)
at android.app.Activity.startActivityFromChild(Activity.java:3472)
at android.app.Activity.startActivityForResult(Activity.java:3224)
at cn.safetrip.edog.function.map.h.onClick(HomeActivity.java:970)
at     com.android.internal.app.AlertController$ButtonHandler.handleMessage(AlertController.java:169)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:4624)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:809)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:576)
at dalvik.system.NativeStart.main(Native Method)

试试这个:

 startActivityForResult(new Intent(android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS), 0);

相关内容

  • 没有找到相关文章

最新更新