-1
我想通過android 5.0中的應用程序打開設置屏幕,即棒棒糖。 當我下提到的代碼中使用,應用程序崩潰:Android:如何在android棒棒糖中打開設置屏幕
Intent mSettingIntent = new Intent(Settings.ACTION_SETTINGS);
mSettingIntent.addCategory(Intent.CATEGORY_LAUNCHER);
startActivity(mSettingIntent);
的logcat:
01-21 17:28:39.110: E/AndroidRuntime(): android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.settings.SETTINGS cat=[android.intent.category.LAUNCHER] }
01-21 17:28:39.110: E/AndroidRuntime(): at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1771)
01-21 17:28:39.110: E/AndroidRuntime(): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1491)
01-21 17:28:39.110: E/AndroidRuntime(): at android.app.Activity.startActivityForResult(Activity.java:3769)
01-21 17:28:39.110: E/AndroidRuntime(): at android.app.Activity.startActivityForResult(Activity.java:3730)
01-21 17:28:39.110: E/AndroidRuntime(): at android.app.Activity.startActivity(Activity.java:4040)
01-21 17:28:39.110: E/AndroidRuntime(): at android.app.Activity.startActivity(Activity.java:4008)
01-21 17:28:39.110: E/AndroidRuntime(): at com.example.settingoption.MainActivity$1.onClick(MainActivity.java:28)
01-21 17:28:39.110: E/AndroidRuntime(): at android.view.View.performClick(View.java:4802)
01-21 17:28:39.110: E/AndroidRuntime(): at android.view.View$PerformClick.run(View.java:20101)
01-21 17:28:39.110: E/AndroidRuntime(): at android.os.Handler.handleCallback(Handler.java:810)
01-21 17:28:39.110: E/AndroidRuntime(): at android.os.Handler.dispatchMessage(Handler.java:99)
01-21 17:28:39.110: E/AndroidRuntime(): at android.os.Looper.loop(Looper.java:189)
01-21 17:28:39.110: E/AndroidRuntime(): at android.app.ActivityThread.main(ActivityThread.java:5532)
01-21 17:28:39.110: E/AndroidRuntime(): at java.lang.reflect.Method.invoke(Native Method)
01-21 17:28:39.110: E/AndroidRuntime(): at java.lang.reflect.Method.invoke(Method.java:372)
01-21 17:28:39.110: E/AndroidRuntime(): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:950)
01-21 17:28:39.110: E/AndroidRuntime(): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:745)
把你的Logcat輸出 – 2015-01-21 04:36:18
不需要這行 - mSettingIntent.addCategory(Intent.CATEGORY_LAUNCHER); – 2016-05-16 16:26:04