/**
* 安装App内置的别的App
*
* @param context
* @param fileName
*/
public static void installOtherApp(Context context, String fileName) {
try {
InputStream is = context.getAssets().open(fileName);
File file = new File(Environment.getExternalStorageDirectory()
+ File.separator + fileName);
file.createNewFile();
FileOutputStream fos = new FileOutputStream(file);
byte[] temp = new byte[1024];
int i = 0;
while ((i = is.read(temp)) > 0) {
fos.write(temp, 0, i);
}
fos.close();
is.close();
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.setDataAndType(Uri.parse("file://" + file),
"application/vnd.android.package-archive");
context.startActivity(intent);
} catch (Exception e) {
e.printStackTrace();
}
}
转载于:https://my.oschina.net/spoon2014/blog/474663