I know I can install an Android application programmatically by the below code which passes the URI of an APK file. Can I install the application without passing an APK file URI? For example, getting the byte array of an APK file and installing it?
File appFile = new File("application.apk");
Intent installIntent = new Intent(Intent.ACTION_VIEW);
installIntent.setDataAndType(Uri.fromFile(appFile),"application/vnd.android.package-archive");
startActivity(installIntent);
When you install an application this way, you aren’t actually directly installing the application. What happens is that you start the installer and pass the installer a reference to the APK that you want to have installed. The installer isn’t part of your application code and has no access to the memory in your application’s process.
The only way to do this, if you have a byte array containing the APK, would be to write the byte array to a file and then start the installer and pass it a URI that points to the file that you’ve written. Once the installation is complete you could then delete the file (so as not to leave random garbage on the user’s phone).