Fix install on Android 2.3
Cause: setType clears previously setUri. Fixes #718
This commit is contained in:
parent
f4de353900
commit
318f95b51e
@ -89,7 +89,6 @@ public class DefaultInstallerActivity extends FragmentActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Intent intent = new Intent();
|
Intent intent = new Intent();
|
||||||
intent.setData(uri);
|
|
||||||
|
|
||||||
// Note regarding EXTRA_NOT_UNKNOWN_SOURCE:
|
// Note regarding EXTRA_NOT_UNKNOWN_SOURCE:
|
||||||
// works only when being installed as system-app
|
// works only when being installed as system-app
|
||||||
@ -97,22 +96,25 @@ public class DefaultInstallerActivity extends FragmentActivity {
|
|||||||
|
|
||||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
|
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
|
||||||
intent.setAction(Intent.ACTION_VIEW);
|
intent.setAction(Intent.ACTION_VIEW);
|
||||||
intent.setType("application/vnd.android.package-archive");
|
intent.setDataAndType(uri, "application/vnd.android.package-archive");
|
||||||
} else if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {
|
} else if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {
|
||||||
intent.setAction(Intent.ACTION_INSTALL_PACKAGE);
|
intent.setAction(Intent.ACTION_INSTALL_PACKAGE);
|
||||||
|
intent.setData(uri);
|
||||||
intent.putExtra(Intent.EXTRA_RETURN_RESULT, true);
|
intent.putExtra(Intent.EXTRA_RETURN_RESULT, true);
|
||||||
intent.putExtra(Intent.EXTRA_NOT_UNKNOWN_SOURCE, true);
|
intent.putExtra(Intent.EXTRA_NOT_UNKNOWN_SOURCE, true);
|
||||||
intent.putExtra(Intent.EXTRA_ALLOW_REPLACE, true);
|
intent.putExtra(Intent.EXTRA_ALLOW_REPLACE, true);
|
||||||
} else if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) {
|
} else if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) {
|
||||||
intent.setAction(Intent.ACTION_INSTALL_PACKAGE);
|
intent.setAction(Intent.ACTION_INSTALL_PACKAGE);
|
||||||
|
intent.setData(uri);
|
||||||
intent.putExtra(Intent.EXTRA_RETURN_RESULT, true);
|
intent.putExtra(Intent.EXTRA_RETURN_RESULT, true);
|
||||||
intent.putExtra(Intent.EXTRA_NOT_UNKNOWN_SOURCE, true);
|
intent.putExtra(Intent.EXTRA_NOT_UNKNOWN_SOURCE, true);
|
||||||
} else { // Android N
|
} else { // Android N
|
||||||
intent.setAction(Intent.ACTION_INSTALL_PACKAGE);
|
intent.setAction(Intent.ACTION_INSTALL_PACKAGE);
|
||||||
intent.putExtra(Intent.EXTRA_RETURN_RESULT, true);
|
intent.setData(uri);
|
||||||
intent.putExtra(Intent.EXTRA_NOT_UNKNOWN_SOURCE, true);
|
|
||||||
// grant READ permission for this content Uri
|
// grant READ permission for this content Uri
|
||||||
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
||||||
|
intent.putExtra(Intent.EXTRA_RETURN_RESULT, true);
|
||||||
|
intent.putExtra(Intent.EXTRA_NOT_UNKNOWN_SOURCE, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user