我正在尝试使用 Intent 通过蓝牙共享文件,但我不知道为什么它向我显示“无法打开文件进行共享”,我也在不同的文件上尝试过,但效果相同,我正在分享我在 list 中使用的代码和权限...
String sharePath = Environment.getExternalStorageDirectory().getAbsolutePath() + "/Pictures/Aaa.jpg";
Uri uri = Uri.parse(sharePath);
Intent share = new Intent(Intent.ACTION_SEND);
share.setType("image/*");
share.putExtra(Intent.EXTRA_STREAM, uri);
startActivity(Intent.createChooser(share, "Share Sound File"));
到目前为止我已添加的权限
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
最佳答案
试试这个
File sourceFile = new File("//mnt/sdcard/TviderFB.apk");
Intent intent = new Intent();
intent.setAction(Intent.ACTION_SEND);
Intent.setType("image/jpeg");
intent.putExtra(Intent.EXTRA_STREAM,Uri.fromFile(sourceFile));
startActivity(intent);
或者 仔细阅读并实现此 How to send file using bluetooth on android programatically?
或阅读本教程以通过蓝牙分享 http://kpbird.blogspot.in/2011/04/android-send-image-via-bluetooth.html
并且不要忘记在 list 中声明权限
关于java - 无法从外部存储打开文件以通过蓝牙共享,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30295796/