I have a method that does an app update which works perfectly until sdk version 26.
In 26 it opens the Activity and then promptly closes it again without any (obvious) exception or warning being thrown.
I don't see any docs on new permissions or anything that is necessary. If I just change the minSdkVersion to 25 it works fine again.
Would love know what changes in 26 and how to address it.
Here's the relevant code segment, but as I said, it's not "broken" - it's just kind of silently failing in 26.
if (Build.VERSION.SDK_INT <= android.os.Build.VERSION_CODES.M) {
Log.d(TAG, "Marshmallow or lower");
intent.setDataAndType(Uri.fromFile(file), "application/vnd.android.package-archive");
}
//if version 24 or above
else {
Log.d(TAG, "higher than Marshmallow");
Uri uri = FileProvider.getUriForFile(mContext, mContext.getApplicationContext().getPackageName() + ".provider", file);
intent.setDataAndType(uri, "application/vnd.android.package-archive");
}
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
mContext.startActivity(intent);
Did you try adding the below permission to manifest?
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
There are changes made in Android Oreo to make installation of apps from outside of playstore safer. You can get more info at below link:
https://android-developers.googleblog.com/2017/08/making-it-safer-to-get-apps-on-android-o.html