Say, a file explorer now used FileProvider to open an apk file, well, use the intent like the following:
intent.setDataAndType(apkFileUri, "application/vnd.android.package-archive");
I have set up intent-filter in the received activity like this:
<action android:name="android.intent.action.VIEW" />
<data
android:mimeType="application/vnd.android.package-archive"
android:scheme="content" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
The point is that how could I get the absolute path of this file from the uri? This uri is not like content or file + absolute path but some personal defined paths by the developers. I retrieved the path by uri.getPath() from different explorers and I got following:
/file/storage/emulated/0/myMessage-global-xxhdpi-debug-1.6.0.apk
/external/file/65971
I need the absolute path of apk file so that I can use the method in PackageManager to get PackageInfo of apk file to show the detailed information like permissions needed, version code and e.t.c. So I really need the absolute path of APK file. I searched around and I know I could get the path if the format is image or audio. But I need apk path.
getPackageArchiveInfo(String archiveFilePath, int flag)