Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>My recommendation: <strong>Don't do that</strong> unless it's like a corporate-type thing.</p> <p>But. In <code>onDisableRequested()</code>, you could <code>startActivity</code> for the home screen, and then <code>startActivity</code> for an <code>Activity</code> you created that confirms whether they want to continue or not. If they choose yes, then you do as you desire (wipe the device), if they say no, then just <code>startActivity</code> for the home screen again (or <code>finish()</code>).</p> <p>This does still run the risk that they can launch the same settings page from the recent tasks, under which circumstance they will likely be able to press "yes" (or ok) on the dialog that popped up with your custom text and then continue with disabling device admin. To try and avoid that from happening, you could do <a href="https://stackoverflow.com/a/7025020/802469">this</a> in the hopes it will start the initial settings page and clear the top-most disable device admin screen. </p> <p>Instead of wiping, you could always do <code>resetPassword("new password")</code> and then <code>lockNow()</code>. If it's a security-related app, then the person's device doesn't have to be wiped, and the password would have been pre-defined by the person who installed the app.</p> <p>Let me know if you have any other questions. I hope this helps.</p> <p><strong>EDIT:</strong> I got an upvote that reminded me this answer exists, so I figured I'd add some info. </p> <p>You could use <code>lockNow()</code> in conjunction with an Activity that will show on top of the lock screen if you want to lock then still offer the wipe or whatever else.<br> And locking before starting the wipe would be a good idea to prevent problems if the wipe has an error or delay for any reason.</p> <p>And if doing anything like this on a distributed app (via app stores), take care not to violate their polices because a policy violation CAN cause a permanent ban from the app store (it happened to me on Google Play, due to nothing more than a misunderstanding.)</p>
    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.
 

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