if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && ContextCompat.checkSelfPermission(this, Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
Intent i = new Intent(Settings.ACTION_APPLICATION_SETTINGS, Uri.parse("package:" + getPackageName()));
finish();
startActivity(i);
return;
}
我尝试检查上面的sdk版本marshmello,但每次我试图运行它,总是会导致这样的错误
12-26 08:21:16.982 6330-6330/com.example.asus.retrofittest3 E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.asus.retrofittest3, PID: 6330
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.asus.retrofittest3/com.example.asus.retrofittest3.HomeActivity}: android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.settings.APPLICATION_SETTINGS dat=package:com.example.asus.retrofittest3 }
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2706)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2767)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1514)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:163)
at android.app.ActivityThread.main(ActivityThread.java:6205)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:904)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:794)
Caused by: android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.settings.APPLICATION_SETTINGS dat=package:com.example.asus.retrofittest3 }
at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1816)
at android.app.Instrumentation.execStartActivity(Instrumentation.java:1525)
at android.app.Activity.startActivityForResult(Activity.java:4402)
at android.support.v4.app.BaseFragmentActivityApi16.startActivityForResult(BaseFragmentActivityApi16.java:54)
at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:67)
at android.app.Activity.startActivityForResult(Activity.java:4360)
at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:720)
at android.app.Activity.startActivity(Activity.java:4699)
at android.app.Activity.startActivity(Activity.java:4667)
at com.example.asus.retrofittest3.HomeActivity.onCreate(HomeActivity.java:49)
at android.app.Activity.performCreate(Activity.java:6864)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1119)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2659)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2767)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1514)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:163)
at android.app.ActivityThread.main(ActivityThread.java:6205)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:904)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:794)
不确定它出错的地方,已经尝试过stackoverflow的一些建议,但它仍然没有解决它
答案 0 :(得分:0)
您在此处的设置操作:vmSearchBarInputDidChange = false // reset
(活动操作:
显示允许配置与应用程序相关的设置的设置。)您没有权限。请将其更改为ACTION_APPLICATION_SETTINGS
(活动操作:显示有关特定应用程序的详细信息的屏幕。)。
<强>从强>:
ACTION_APPLICATION_DETAILS_SETTINGS
以强>:
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && ContextCompat.checkSelfPermission(this, Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
Intent i = new Intent(Settings.ACTION_APPLICATION_SETTINGS, Uri.parse("package:" + getPackageName()));
finish();
startActivity(i);
return;
}
答案 1 :(得分:0)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && ContextCompat.checkSelfPermission(this, Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
Intent i = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS, Uri.parse("package:" + getPackageName()));
finish();
startActivity(i);
return;
}