/**
* 将apk的assets目录中的apk复制到sdcard,然后安装。
* @param context
* @param apkName
*/
private void installApk(Context context, String apkName){
try {
FileOutputStream out = new FileOutputStream("/sdcard/data/data/apk2.apk");
InputStream in = context.getResources().getAssets().open(apkName);
byte[] buffer = new byte[1024];
int length = in.read(buffer);
while(length > 0){
out.write(buffer);
System.out.println(length);
length = in.read(buffer);
}
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.fromFile(new File("/sdcard/data/data/apk2.apk")),
"application/vnd.android.package-archive");
context.startActivity(intent);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}