My application minSdkVersion is 19 and application installs 3rd party app using following code,
Intent intent = Intent(android.content.Intent.ACTION_VIEW);
intent.setDataAndType(android.net.Uri.fromFile(new java.io.File(APK_PATH)),
"application/vnd.android.package-archive");
intent.setFlags(android.content.Intent.FLAG_ACTIVITY_NEW_TASK);
I have Added permission in manifest file,
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES"/>
The above code is working well up to android version 9, but in Android 10 is not working and no logs found. I have gone through some docs, ACTION_VIEW or ACTION_INSTALL_PACKAGE is deprecated on Android 10. PackageInstaller is a new API for install 3rd party apps but PackageInstaller is added in API level 21.
Is there any way to use PackageInstaller below API level 21? How can I install 3rd party app in Android 10??