How to uninstall other apps

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…

Eureka… Now it worked… as pointed out by @Boban i should build it. It wont work in companion. Thanks @anke, Taifun vknow360 here is final code… must built it to run…
uninstall (5).aia (15.2 KB)

Here is working code snippest.

1 Like

Of course not with Companion, because the permission (REQUEST_DELETE_PACKAGES) is not declared in Companion (apk).

And as I already said, you cannot uninstall a pre-installed system app (like YouTube). There is no problem to unintall all other apps.

Btw, if you post the same story also in the Kodular forum, then at least let us know.

Here is a test aia: un_installAPK.aia (3.0 MB)

Note : InstallApp does not seem to work on Android > 5:

See also here: