当前位置: 代码迷 >> Android >> Android之——通用安装apk步骤
  详细解决方案

Android之——通用安装apk步骤

热度:19   发布时间:2016-04-27 23:57:28.0
Android之——通用安装apk方法
转载请注明出处: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"/>

版权声明:本文为博主原创文章,未经博主允许不得转载。

  相关解决方案