2

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

    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)

我不知道...

4

1 回答 1

8

试试这个:

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

以及您输入代码的活动名称是什么。

于 2013-04-12T12:37:23.327 回答