PkgUtils : An extension to work with Packages

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 @hammerhai
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.

Sure.
But I donā€™t think it is because of try-catch.
Letā€™s see if your work.

Which extension?

1 Like

Think you found it :slight_smile: just go to the Archive component and you should find the block

2 Likes

Great, works, but I wouldnā€™t have supposed it there, but rather at AppManager.

1 Like

Maybe off topic, but what is this for:

EDIT: Got it.

1 Like

You mean you are able to install app with @hammerhai 's extension.

I first checked with Companion: works.
But APK seems to fail.

Hmmm. Did you check your path for both of ours? Try /mnt/sdcard/Downloads/filename.apk

@bodymindpower @vknow360 Iā€™m going to test a fix and see if it works.

As expected the same error:

Companion works.

Hi @bodymindpower
1.Is PkgUtils behaving same?
2.Can you please send me the logcat?