Android:恢复出厂设置

只有在开发Launcher和Setting通常才会用到恢复出厂设置,恢复出厂设置在应用层开发相对来讲比较简单,就是发送广播。android

Android 9.0以前git

Intent intent = new Intent(Intent.ACTION_MASTER_CLEAR);
sendBroadcast(intent);
复制代码

Android 9.0bash

Intent resetIntent = new Intent("android.intent.action.FACTORY_RESET");
resetIntent.setPackage("android");
sendBroadcast(resetIntent);
复制代码

固然,要恢复出厂设置,当前APK须要具备系统属性。在AndroidManifest.xml的标签manifest添加android:sharedUserId="android.uid.system"ui

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.gitcode.settings"
    android:sharedUserId="android.uid.system"
    android:versionCode="16"
    android:versionName="1.6" >
复制代码
相关文章
相关标签/搜索