需求:点击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);