PkgUtils : An extension to work with Packages

Yes, but what does that have to do with a test of the app. Of course, it makes sense to test the app on Android 10 as well.

2 Likes

Done …

1 Like

1 Like

Same Issue.

1 Like

Try also the second version:
file:///storage/...

uninstallAPK_2.apk - Google Drive

grafik

1 Like

When clicked on install app nothing happens.

1 Like

Yes nothing will happen.
Because it uses absolute file path not an uri or relative file path.

Yes, but both are absolute paths:

/storage/emulated/0/Download/testApp.apk
file:///storage/emulated/0/Download/testApp.apk

No.This one is uri :arrow_down:

No, both are uri.

A relative path would be:
/Download/testApp.apk

Regarding FileProvider and ContentProvider (uri & file:///) read this:

https://developer.android.com/reference/android/support/v4/content/FileProvider.html

Kodular / AI2 -> support library

1 Like

Thank you @bodymindpower
Let me clear it.
Here is the code I am using:

 public void InstallApp(String apkFilePath){
    File f = new File(apkFilePath);
    if (f.exists()){
        try {
            Intent intent = new Intent("android.intent.action.VIEW");
            intent.addCategory("android.intent.category.DEFAULT");
            if (Build.VERSION.SDK_INT < 24) {
                intent.setDataAndType(Uri.fromFile(f), "application/vnd.android.package-archive");
            }else{
                Uri uri = FileProvider.getUriForFile(context,context.getPackageName()+".provider",new File(apkFilePath));
                intent.setDataAndType(uri,"application/vnd.android.package-archive");
            }
            context.startActivity(intent);
        }catch (Exception e){
            e.printStackTrace();
        }
    }
}

There are few lines which needs to be changed according to this thread:

1 Like

How can we do that

Hi
I am unable to understand what you said.

About this

As I have already said that is not possible at this time.

When I used unistall app component I have that apk installed but when I click it said that package not found but I have

Since it uses PackageManager class(which is famous for throwing this type of errors) so I think you have typed wrong package name.

Ok let me verify

1 Like

Two methods not working in Android 9