步步为营_Android开发课_番外篇[5]_软件的安装与卸载源码

Focus on technology, enjoy life!—— 杨焕州 QQ:804212028
原文链接:http://blog.csdn.net/y18334702058/article/details/44624305
本文可能存在参考或借助部分外界资源,如有任何侵权行为,请与我联系!


  • 主题:软件的安装与卸载源码

从SDcard安装软件:

String fileName = Environment.getExternalStorageDirectory()
        + "/myApp.apk";
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.parse("file://" + filePath),
        "application/vnd.android.package-archive");

或者用

/**
intent.setDataAndType(Uri.fromFile(new File(fileName)),
        "application/vnd.android.package-archive");
*/
startActivity(intent);

卸载软件

Uri packageURI = Uri.parse("package:com.android.myapp");
Intent uninstallIntent = new Intent(Intent.ACTION_DELETE, packageURI);
startActivity(uninstallIntent);

Focus on technology, enjoy life!—— 杨焕州 QQ:804212028
原文链接:http://blog.csdn.net/y18334702058/article/details/44624305

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。