I just did that right now ...
I put apk 2 in raw/embeddedapk.apk
then this code ... started the installer for apk 2 ... **problem if user phone doesnt allow application not from market .. it will fail to install apk 2 ...
remember to delete temp file when the instalation is finished ....
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 I want to have apk 1 userinterface and apk 2 data provider as seperate apps in market. but i don't wnat users to down then individually when installing first time ...
apk 1 need data from apk 2, apk 2 does not have any activities ..
When user downloads apk 1 from market I want to auto instal apk 2 ...
I want to be able to update (market) apk1 & apk 2 independantly ...
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…