PkgUtils : An extension to work with Packages

Hi @Vinod_Kotiya Welcome to Kodular Community
Since I have not tested that method on all android versions so I am not sure on which versions it will not work.
Can you provide more details?

1 Like

@vknow360 Please add this permission to the Manifest, to be able to uninstall package from devices with API > 28:

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

See here:

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

3 Likes

Thank you @bodymindpower :heart_eyes:
I will try to fix it as soon as possible :+1:

2 Likes

Great, and also add this permission:

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

to install package on devices with API > 25.

1 Like

Thank you.

I have already added all necessary permissions and just going to test it :smile:

1 Like

ChangeLog Verson 3

Changes

  • Added necessary permissions in extension
    Thanks to @bodymindpower
  • Fixed grammar and spelling mistakes
  • Some internal changes to reduce aix size (16.1 > 14.2 KB)
3 Likes

Great service, updating so quickly. :+1:

5 Likes

It is one of the best extension developers :heart_eyes:

1 Like

vknow360 Anke Hi, Thanks for your support. I am affraid. It is still not working. I tried new AIX, source code attached here.
Sunny this uninstall instruction is unresponsive. Hope you can find the glitch or give proper sample code. Thanks.
uninstall (4).aia (15.2 KB)

You might need to build your app, as those permissions above won’t work in companion

2 Likes

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)

1 Like

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

And as I already said in the AI2 forum, 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 AI2 forum , then at least let us know.

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

grafik

un_installAPK.apk (9.9 MB)

See also here:

Hi

Can you send me the logcat?

It’s likely not an issue with their device. It’s your method that you are using.

@bodymindpower can you try the method I used in my extension? If it works for you I’ll hand over the snippet. It works on Android O for me.

Thank you @Stormi
I am using same method but with a modification.
Here is my code:

 public void InstallApp(String apkFilePath){
    File f = new File(apkFilePath);
    if (f.exists()){
        try {
            Intent intent = new Intent("android.intent.action.VIEW");
            intent.setDataAndType(Uri.fromFile(f), "application/vnd.android.package-archive");
            context.startActivity(intent);
        }catch (Exception e){
            e.printStackTrace();
        }
    }
}

Use this…

java.io.File apk = new java.io.File(file);
Intent intent = new Intent("android.intent.action.VIEW");
intent.addCategory("android.intent.category.DEFAULT");
intent.setDataAndType(Uri.fromFile(apk), "application/vnd.android.package-archive");
context.startActivity(intent);

Of course you can modify it to your liking with checking if the file exists.

Ooops…I posted code of v4 :sweat_smile:
In version 3 I am using same code (I mean with category).
I thought that issue is due to specifying Category so I removed that.

Remove the try-catch then come back with V4. In any of the examples, if you were paying attention, there is no try-catch.