The associated APK is placed under the Assets Directory. The Code is as follows, but the installation is displayed when the associated APK is installed.
Private file getassetfile (){
Assetmanager asset = mainactivity. This. getassets ();
Try {
Inputstream is = asset. Open ("zxing.apk ");
Fileoutputstream Fos = This. openfileoutput ("zxing.apk", context. mode_private + context. mode_world_readable );
Byte [] buffer = new byte [1024];
Int Len = 0;
While (LEN = is. Read (buffer ))! =-1 ){
FOS. Write (buffer, 0, Len)
}
FOS. Flush ();
Is. Close ();
FOS. Close ();
Return new file ("zxing.apk ");
} Catch (ioexception e ){
// Todo auto-generated Catch Block
E. printstacktrace ();
}
}
Private void installapk (File file ){
Intent intent = new intent ();
Intent. addflags (intent. flag_activity_new_task );
Intent. setaction (intent. action_view );
String type = "android/vnd. Android. Package-Archive ";
Intent. setdataandtype (URI. From (file), type );
Startactivity (intent );
}