我的应用程序中创建了一个 Zip 文件,现在我想在 Android 手机中的其他应用程序(例如蓝牙或 Gmail 或...)上共享此 Zip 文件。 我用的是这个:
Intent shareIntent = new Intent();
shareIntent.setAction(Intent.ACTION_SEND);
shareIntent.putExtra(Intent.EXTRA_STREAM, zipName);
shareIntent.setType("*/*");
activity.startActivity(Intent.createChooser(shareIntent,activity.getResources().getText(R.string.send_to)));
zipname 是我的 zip 文件路径。 该代码是通过按下按钮来执行的。将弹出一个包含所有应用程序的列表,但是通过单击蓝牙,只会关闭弹出窗口,而不会关闭其他任何内容!
为什么?请帮我。我需要打开蓝牙并打开蓝牙,....最佳答案
我自己解决了这个问题,zipname是文件的路径,但它需要是uri,所以我使用了这个代码
shareIntent.putExtra(Intent.EXTRA_STREAM, uri.fromfile(new File(zipName)));
而不是
shareIntent.putExtra(Intent.EXTRA_STREAM, zipName);
关于android - 通过蓝牙共享 zip 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13893997/