如何在Intent中添加.apk文件 [英] How to add .apk file inside intent

查看:96
本文介绍了如何在Intent中添加.apk文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在intent中添加.apk文件。我想创建一个共享按钮,该按钮将通过蓝牙或具有发送应用程序功能的任何其他应用程序共享整个应用程序。如果可以通过其他方式完成,请告诉我!
谢谢

I want to add .apk file inside intent. I want to create a button "Share" which will share the whole app through bluetooth or any other application which have capability to send application. If this can be done by other way then please tell me! Thanks

推荐答案

 List(ApplicationInfo) mAppList=getPackageManager().getInstalledApplications(0);        
ApplicationInfo item = mAppList.get(position);



 public static void ShareAPK(ApplicationInfo item,Context ctx) {
    try {
        File srcFile = new File(item.publicSourceDir);
        Intent share = new Intent();
        share.setAction(Intent.ACTION_SEND);
        share.setType("application/vnd.android.package-archive");
        share.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(srcFile));
        ctx.startActivity(Intent.createChooser(share, "Sharing"));
    } catch (Exception e) {
        e.printtrace();
    }

}

这篇关于如何在Intent中添加.apk文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆