需求:点击Button,跳转至 系统设置页面。
旧方法:
Intent intent = new Intent();
intent.setClassName("com.android.settings", "com.android.settings.Settings");
startActivity(intent);报错的设备型号:HUAWEI MT7-TL10
报错信息:
<span style="color:#ff0000;">java.lang.SecurityException: Permission Denial: starting Intent { cmp=com.android.settings/.Settings } </span><span style="color:#ff0000;">from ProcessRecord{431bdca8 4328:com.com.example.test/u0a177} (pid=4328, uid=10177) not exported from uid 1000</span>
新方法:
Intent intent = new Intent(Settings.ACTION_SETTINGS);
startActivity(intent);
本文介绍了一种从应用中跳转到系统设置页面的方法。针对旧方法在特定设备上出现的权限拒绝错误,提供了一个简单且兼容性更好的新方法。
1659

被折叠的 条评论
为什么被折叠?



