I'd like to know if it is possible to trigger programmatically the installation of an apk that is on the card ?
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.fromFile(new File(fileName)), "application/vnd.android.package-archive");
startActivity(intent);
(courtesy of anddev.org)
Just in case somebody is looking for this info.... If you want to install an apk which you also programmatically downloaded and stored in your private "files" folder (ie. "/data/data/com.yourapp.name/files"), you need to get the uri for the full path by first using getFileStreamPath as follows:
File fullPath = getFileStreamPath("name_of_downloaded_app.apk");
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.fromFile(fullPath), "application/vnd.android.package-archive");
startActivity(intent);
Hope this helps...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With