-1

I need to trigger an uninstall of a certain app from within my own app. The only thing i have is the apps apk, even tho it doesn't have to be the same version as the installed app.
The uninstall would be handled by android of course. Just like installing an app from a given apk file.

Is there a way how i can put together an intent to make android open the responsible system service and and ask the user to uninstall or something like that?

The app to be uninstalled can change, so i can't use a constant packagename or something like that.

Is there some way to do this? I know you can extract the packagename from an apk, but it seems like a lot of work and probably overkill.

Basti
  • 1,117
  • 12
  • 32
  • 2
    No, you can't do this. If this is can be possible, there is no competition of developer on Play Store. Think before ask. – Arbaz Alam Mar 27 '18 at 08:41
  • @ArbazAlam The uninstall would have to be confirmed by user of course. The uninstall it self would be handled by android, just like installing an app from a given apk file. Once passed to the system the responsible system service opens and the user needs to interact. You can delete apps from within apps like this if you have to the apps package name. But i only have the apk – Basti Mar 27 '18 at 08:46
  • If all the information you have is the APK, I don't see how you could avoid extracting the data from inside it. – JJJ Mar 27 '18 at 08:48
  • @JJJ Is there maybe some easy way provided by android to retrieve the package name an apk file? – Basti Mar 27 '18 at 08:51

1 Answers1

1

Using Intent.ACTION_DELETE intent

Intent intent = new Intent(Intent.ACTION_DELETE);
intent.setData(Uri.parse("package:com.example.mypackage"));
startActivity(intent);

You can get your own package name from context;

getApplicationContext().getPackageName();
Rajesh Gopu
  • 863
  • 9
  • 33
  • I only have the apk. Not the package name. Would have to extract it, seems like a lot of work tho. – Basti Mar 27 '18 at 08:50
  • 1
    I am also not trying to uninstall my own app. My app downloads apks from a repository and provides install/update/uninstall functions for those. The problem is, that i only have apk-files of other apps and no package name. To trigger a uninstall, a package name seems to be required – Basti Mar 27 '18 at 08:58
  • 1
    True, but every .apk file contains an `AndroidManifest.xml` from which you extract the package name. It's actually quite easy (and .apk is just a .zip file) – Ch4t4r Mar 27 '18 at 09:04