How to uninstall other apps

Hi
I want to uninstall other app using package installer when a button is clicked on my app.
I am supplying package name in datauri parameter which needs to be uninstalled.

I have tried all possible methods but failed so far. Here is my code.

Sample Code:
uninstall (2).aia (2.2 KB)

See here: App Inventor Code Snippets | Pura Vida Apps

Hi
I tried this first. It is not at all working . then i came to current solution after so much of researchā€¦ I would be greatfull if someone share me a working code aia fileā€¦

See here:

and add the following permissions in the Manifest:

  • REQUEST_INSTALL_PACKAGES
  • WRITE_EXTERNAL_STORAGE

Thanks Anke for your efforts. This is for installation. But i am looking for uninstallation popup for other appsā€¦ I researched and found this task not required any permissions, When you click the button it will go to package installer which ask do you want to remove this app kind of thing which is quite simple in native appā€¦

Hi
Here is the aia file i created for testing. It is not giving popup for uninstallation. Suppose i want to uninstall youtube .
uninstall (2).aia (2.2 KB)

Hi
if someone could rewrite this code then my problem will be solved.

public void run() {
                    try {
                        Uri packageUri = Uri.parse(getPackageName());
                        Intent uninstallIntent =
                                new Intent(Intent.ACTION_DELETE, packageUri);
                        uninstallIntent.putExtra(Intent.EXTRA_RETURN_RESULT, false);
                        //new Intent(Intent.ACTION_UNINSTALL_PACKAGE, packageUri);
                        startActivity(uninstallIntent);
                    } catch (Exception e) {
                        e.printStackTrace();

                        Uri packageURI = Uri.parse(getPackageName());
                        Intent uninstallIntent = new Intent(Intent.ACTION_UNINSTALL_PACKAGE, packageURI);
                        startActivity(uninstallIntent);
                    }
                }

Ok, here is the solution.
Try this (using the PkgUtils extension): uninstallAPK.aia (16.3 KB)

1 Like

Thanks Anke. You found me a nice library. I tried it all code of this extension working except uninstallation oneā€¦ I have put the code here ā€¦
uninstall (3).aia (17.2 KB)

What it seems to me that uninstall is prohibited in Android that too in MIT App inventor only. I saw native apps doing same easily.

Ok, I checked on my Android 9 device (I had previously tested on an Android 5 device.)

We have to add this line to the Manifest for API >= 28:

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

To customize the Manifest see here:

I'll ask the extension developer to add this permission to the Manifest.
He'll do it very quickly, as I know him.

See here: https://developer.android.com/reference/android/Manifest.permission

As I said, very quickly ā€¦

1 Like

Superā€¦ Thanks Anke for your supportā€¦ Hope it will solveā€¦ I will upload finished work here if it worksā€¦

@vknow360 has already updated his extension:

1 Like

thank you for trying... this once worked in older Android versions...
I will add a note in my webpage and link to this thread
thank you @Anke and @vknow360

Taifun


Trying to push the limits! Snippets, Tutorials and Extensions from Pura Vida Apps by Taifun.

3 Likes

Hi @Taifun
You may need to update your snippet.
It can be done easily using activity.
Once I open pc I will share the code here.
If I am not wrong :sweat_smile: then I have used code from here:

2 Likes

@Taifun @Anke Hi, Thanks for your support. I am affraid. It is still not working. I tried new AIX, source code attached here.
Nice to see Taifun on my thread. Thanks buddy your snippest helped alot on MIT.

uninstall (4).aia (15.2 KB)

1 Like

You want to uninstall YouTube (a pre-installed system app). So far there has been no talk of this. This requires either a rooted device or something else ...

All other (non-system) apps can be uninstalled without any problems.

1 Like

No I took youtube just as a testcase so that debugging would be easy as it is in all deviceā€¦ I tried it with camscanner app also by changing package to com.intsig.camscanner but still it is non responsiveā€¦