android - 如何在 intent 中添加 .apk 文件

标签 android android-intent android-sharing

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

最佳答案

 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();
    }

}

关于android - 如何在 intent 中添加 .apk 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24852825/

相关文章:

android - 如何使用 JSON 对象传递 JSON 数组

android - 当我在 Lollipop 5.1 中单击浏览器上的共享时,我的应用程序不显示

android - Intent.createChooser : How we can check sharing image intent count?

java - android文件共享时的访问权限

Android Play 商店 - 从服务器检索信息时出错。远程过程调用 :S-2:AEC-2

java - Android 手机无法连接到 eclipse

android - Intent.FLAG_ACTIVITY_MULTIPLE_TASK 的使用

java - 安卓 : Getting "null" from intent

android - 如何在Android Studio中检查依赖项的依赖项

android - Titanium - 发送图片到服务器 : file size bug