Android Factory Reset Programmatically

后端 未结 6 1568
悲&欢浪女
悲&欢浪女 2020-12-05 07:53

I tried to perform a factory reset in Android using the RecoverySystem class, but I get permission errors, which I can not overwrite because they are system permissions. I w

6条回答
  •  囚心锁ツ
    2020-12-05 08:20

    This works on a many different devices I have tried. (more than 20)

    Context foreignContext = createPackageContext("com.android.settings", Context.CONTEXT_IGNORE_SECURITY | Context.CONTEXT_INCLUDE_CODE);
    Class yourClass = foreignContext.getClassLoader().loadClass("com.android.settings.MasterClear");
    
    Intent intent = new Intent(foreignContext, yourClass);
    startActivity(intent);
    

提交回复
热议问题