转载请注明出处:http://blog.csdn.net/l1028386804/article/details/46955863
不多说,直接上代码:
public void installApk(){ Intent intent = new Intent(); intent.setAction(Intent.ACTION_VIEW); //根据实际情况获取apk名称 String name = "test.apk"; File file = new File(Environment.getExternalStorageDirectory(),name); intent.setDataAndType(Uri.fromFile(file), "application/vnd.android.package-archive"); startActivity(intent); }
别忘了在AndroidManifest.xml中配置权限
<uses-permission android:name="android.permission.INSTALL_PACKAGES"/>
版权声明:本文为博主原创文章,未经博主允许不得转载。
时间: 2024-11-07 20:08:02