Android : Clear default association with my app

on Friday, December 5, 2014


I have an app which works in two modes:


A Kisok/locked down mode - in this mode the device is to be locked down (as best as possible) to prevent unauthorized access to the device. In this mode clients will buy a device, download the app, enable lockdown features, and hand out to their employees.


A 'user' mode - in this mode our clients will simply direct their employees to the Play store and the employees will run the software on their own devices.


So the 'lockdown' is handled by making the app full-screen and binding it by default to the home button. Out app, however, needs to offer google navigation and google navigation provides web links which would enable a user to fairly easily access the browser. To combat this I've made it so that, via an intent filter, the app can be associated with http documents as standard. This is 'good enough' security to meet the needs of the client.


The issue I have is really one of protecting the users from themselves. If the user (somebody running the app in 'user-mode') has accidentally selected my app as a default handler for http requests, I want to be able to remove my app as the default, then re-pass the intent. Something like this:



Intent i = this.getIntent();
if(i.getAction().equals(Intent.ACTION_VIEW))
{
if(i.getDataString().contains("http"))
{
if(this.isLockdown())
{
//show an error message to the user
}
else
{
// !!Unbind the app as default first
this.startActivity(i); //resend the intent
}
}
}


A couple of points... Firstly, I understand I wouldn't be able to do this if a different app was binded by default, and neither do I want to. This is only for when a user has accidentally binded MY app to be a default. Secondly, I know I could just prompt the user to clear the defaults themselves, and navigate them to the Manage Apps screen, but a large percentage of the potential clientele for this app would still find this difficult - so I'm trying to make it easier for them if at all possible.


0 comments:

Post a Comment