0

I just installed Quick Heel antivirus in my android device. It asked me to set password first, and when I went to uninstall, it asked me for password. I want to add this functionality in my android app, how can I do it?

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();
}
} }

I am able to set password when user uninstalls the app. The problem is, when the user hits uninstall then they're ask to pick the uninstall app(see screenshot). There are two options. The upper one is default option. If they choose it, the the app will uninstall. If user clicks on second option, they will be asked for password.

enter image description here

4

0 回答 0