install and uninstall android app by password authentication

  • Replies:3
Nishu Sharma
  • Forum posts: 2

Feb 28, 2014, 1:49:43 PM via Website

hello everyone,

i am making a security related android app. in which
i want to restrict user to uninstall the android app by password,
at the time of app installation i want to get input password from user and during uninstallation user must enter the same password to uninstall it.
without entering that password he should not uninstall the app.

i searched over internet and asked many android developers but nobody can sort it out.
This type of security exist in quick heal app (quick heal antivirus for mobile), so it is possible.
some says it cant be possible with normal android SDK, it requires administrative API.
some says it cant possible.

please suggest me if anyone have solution

i tried out package watcher through broadcast receiver and reached almost near by to my goal.
but at the time of uninstallation two package installer generates, one is the default (implicit) and one is created by me (explicit).
when user select "my package installer" then he prompt for password and everything goes as desired
but when user selects default package installer then the app got uninstall without asking for password.

anyone here to solve this issue???????

here is the code:-

public class uninstalledActivity extends Activity implements OnClickListener {
EditText edt_pass;
Button btn_ok,btn_cancel;
protected void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.uninstalled);
edt_pass=(EditText)findViewById(R.id.txt_pass);
btn_ok=(Button)findViewById(R.id.btn_ok);
btn_cancel=(Button)findViewById(R.id.btn_cancel);
btn_ok.setOnClickListener(this);
btn_cancel.setOnClickListener(this);
}
public void onClick(View v) {
if(v==btn_ok)
{
if(edt_pass.getText().toString().equals("123"))
{
Toast.makeText(this,"ok", Toast.LENGTH_LONG).show();
Uri packageURI = Uri.parse("package:cb.example.uninstallation demo");
Intent i = new Intent(Intent.ACTION_DELETE, packageURI);
startActivity(i);
}
else
Toast.makeText(this,"password does not match",Toast.LENGTH_LONG).show();
}else
{
finish();
}
}
}

Reply
Pascal P.
  • Admin
  • Forum posts: 11,286

Feb 28, 2014, 2:02:21 PM via Website

I think its difficult to code a function like this.
It can be possible but many developers (me too) program normal apps which do their functions.
The install and uninstall Part do the android system. I don't know if you need administrative api or root rights.
When such an app already exists, then you can write an e-mail to the developer of this app.
He may gives you the answer

LG Pascal //It's not a bug, it's a feature. :) ;)

Reply
Nishu Sharma
  • Forum posts: 2

Feb 28, 2014, 2:07:17 PM via Website

yes i need administrative api.....but i dont know where i find this and how to use it. if you know that then tell me please.

Reply