我想在 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/