Reputation: 2106
I am using this code to install an app from SD card
Toast.makeText(this, "running", Toast.LENGTH_LONG).show();
Intent promptInstall = new Intent(Intent.ACTION_VIEW)
.setDataAndType(Uri.parse("file:///sdcard/app.apk"),
"application/vnd.android.package-archive");
startActivity(promptInstall);
how ever I am getting parse error : There was a problem parsing the package
I have given the permission in manifest file
<uses-permission android:name="android.permission.INSTALL_PACKAGES" />
I have placed the apk in sdcard
ps: app is getting installed via file manager
Upvotes: 1
Views: 983
Reputation: 625
You could change the way you specify the URI. try this;
Intent promptInstall = new Intent(Intent.ACTION_VIEW)
.setDataAndType(Uri.fromFile(new File(Environment.getExternalStorageDirectory()+File.separator+"<DIRECTORY_NAME>"+File.separator+"<YOUR_APK_FILE.apk>")),
"application/vnd.android.package-archive");
startActivity(promptInstall);
Upvotes: 1