Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Third party applications most DEFINITELY can do this.</p> <p>On 2.2+ devices (including latest 4.x) you would have to use the DevicePolicyManager and include permissions in the AndroidManifest.xml. For older devices you can use foreign context loader as described in other answer.</p> <pre><code>import android.app.admin.DevicePolicyManager; import android.content.ComponentName; DevicePolicyManager mDPM; ComponentName mDeviceAdmin; </code></pre> <p>On Create determine there Android version and get handle on objects </p> <pre><code> currentAPIVersion = Build.VERSION.SDK_INT; if (currentAPIVersion &gt;= android.os.Build.VERSION_CODES.FROYO) { //2.2+ mDPM = (DevicePolicyManager)getSystemService(Context.DEVICE_POLICY_SERVICE); mDeviceAdmin = new ComponentName(this, WipeDataReceiver.class); } </code></pre> <p>The WipeDataReceiver class was a class to implement DeviceAdminReceiver, but did not have any overrides or code updates.</p> <pre><code> public static class WipeDataReceiver extends DeviceAdminReceiver { } </code></pre> <p>On Resume, initially the will have to confirm Factory Reset. when the Activity returns result it will perform wipeData. If it's Froyo or less, you can jump the stock factory reset activity.</p> <pre><code>if (currentAPIVersion &gt;= android.os.Build.VERSION_CODES.FROYO) { // 2.2+ if (!mDPM.isAdminActive(mDeviceAdmin)) { Intent intent = new Intent(DevicePolicyManager.ACTION_ADD_DEVICE_ADMIN); intent.putExtra(DevicePolicyManager.EXTRA_DEVICE_ADMIN, mDeviceAdmin); intent.putExtra(DevicePolicyManager.EXTRA_ADD_EXPLANATION, "Process will remove user installed applications, settings, wallpaper and sound settings. Are you sure you want to wipe device?"); startActivityForResult(intent, REQUEST_CODE_ENABLE_ADMIN); } else { // device administrator, can do security operations mDPM.wipeData(0); } } else { // 2.1 try { Context foreignContext = this.createPackageContext("com.android.settings", Context.CONTEXT_IGNORE_SECURITY | Context.CONTEXT_INCLUDE_CODE); Class&lt;?&gt; yourClass = foreignContext.getClassLoader().loadClass("com.android.settings.MasterClear"); Intent i = new Intent(foreignContext, yourClass); this.startActivityForResult(i, REQUEST_CODE_ENABLE_ADMIN); } catch (ClassNotFoundException e) { } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload