I just did it right now ...
I put apk 2 in raw / embeddedapk.apk
then this code ... launched the installer for apk 2 ... ** the problem is if the userβs phone does not allow the application not from the market .. he will not be able to install apk 2 ...
Remember to delete the temporary file when the installation is complete ....
try { InputStream in = this.getResources().openRawResource(R.raw.embeddedapk); byte[] b = new byte[in.available()]; int read = in.read(b); toast(read + " byte read"); String tempFileName = "embeddedapk.apk"; FileOutputStream fout = openFileOutput(tempFileName, MODE_WORLD_READABLE); fout.write(b); fout.close(); in.close(); File tempFile = getFileStreamPath(tempFileName); Intent i = getFileActionIntent(Intent.ACTION_VIEW, tempFile); startActivity(Intent.createChooser(i, "sdsds")); } catch (Exception ex){ Log.e("ero", "erer", ex); }
My reason is because I want apk 1 userinterface and apk 2 data provider to be separate applications on the market. but I donβt want users to be reset individually when installing for the first time ...
apk 1 needs data from apk 2, apk 2 has no action.
When a user downloads apk 1 from the market, I want to use auto instal apk 2 ...
I want to be able to update (sell) apk1 and apk 2 independently ...
source share