0

I am building an application that requires these both permissions to install and uninstall apks silently. My app is going to run in non rooted application. How to get these two permissions!!.

I have added in manifest file

<uses-permission android:name="android.permission.DELETE_PACKAGES"/>
<uses-permission android:name="android.permission.INSTALL_PACKAGES"/>

These permissions doesn't work when i execute these commands to uninstall an apk from my application

Runtime.getRuntime().exec("pm uninstall packagename");

Please help me through these, i have saw one application doing installation and uninstallation without any prompt successfully in my phone(non-rooted). Can anyone tell me, how this is possible?

  • Does this answer your question? [Install apps silently, with granted INSTALL\_PACKAGES permission](https://stackoverflow.com/questions/5803999/install-apps-silently-with-granted-install-packages-permission) – Rahul Pareta Apr 28 '20 at 10:53
  • no this answer is for only rooted one @ rahul – Prashant Kumar Apr 28 '20 at 11:08
  • AFAIK there's no way to programatically get those permissions in recent Android releases. The best you can do is launch the UI to grant those permissions to you and ask the user to please switch them on. That's a security measure because Google doesn't want random apps to be able to install other apps. – Joachim Sauer Apr 28 '20 at 11:34
  • @JoachimSauer i tried launching a normal permission asking ui but when app runs i didn't got any alert to grant these permissions!! Other than than normal permissions asking method if any other method is possible then let me know – Prashant Kumar Apr 28 '20 at 11:42
  • @JoachimSauer https://stackoverflow.com/questions/49828745/how-to-manage-installation-from-unknown-sources-in-android-oreo this answer only help to install packages with prompt i want ti install without prompt – Prashant Kumar Apr 28 '20 at 11:50
  • @PrashantKumar: the simple answer is you can't. Not unless your device is rooted or your app is installed as a privileged app (i.e. installed as part of the system image). That's by design. Installing applications without user applications is a major security issue and Android works very hard to prevent it. – Joachim Sauer Apr 28 '20 at 11:53
  • @JoachimSauer ok... how i can make my app as a privileged app? – Prashant Kumar Apr 28 '20 at 11:56
  • @PrashantKumar: only apps that come pre-installed in the system image (i.e. pre-installed on the phone, not from a store) can be privileged, so unless you ship the physical hardware, you can not. – Joachim Sauer Apr 28 '20 at 11:59
  • @JoachimSauer thank u sir... its's a great help for beginner :) – Prashant Kumar Apr 28 '20 at 12:10

0 Answers0