I need to install apk programatically. I find a method to install it with Intent: install / uninstall APKs programmatically (PackageManager vs Intents)
Intent intent = new Intent(Intent.ACTION_VIEW);
Uri apkUri = Uri.fromFile(new File(Environment.getExternalStorageDirectory() + "/Download/" + "app.apk"));
intent.setDataAndType(apkUri, "application/vnd.android.package-archive");
startActivity(intent);
But, it doesn't work. The problem is the installation activity didn't appear, instead, a list of other programs is displayed for choice:
Could someone tell me what the problem is? Thanks!
Update:
- The permission
android.permission.INSTALL_PACKAGES
is included in manifest. - I am running Android version 2.3 SDK 10