[英]send file using default bluetooth application in android
我想使用我的Android应用程序将文件从手机发送到其他手机。 该文件的类型为“ .Xcard”。 我想使用android环境提供的默认蓝牙应用程序。 也就是说,当我单击send时,默认的应用程序选择器应该打开,然后我应该能够将文件发送到其他设备(通过选择设备)。 我该怎么办? 该文件可能为空,也可能不为空
我尝试了以下代码,但无法正常工作。 我收到一条吐司消息,说:“文件未发送”
f = File.createTempFile("card", ".Xcard", getCacheDir());
FileWriter fw = new FileWriter(f);
BufferedWriter w = new BufferedWriter(fw);
w.write("hello my name is neeraj");
w.close();
Intent i = new Intent();
i.setAction(Intent.ACTION_SEND);
i.setType("*/*");
i.putExtra(i.EXTRA_STREAM, Uri.fromFile(f));
startActivity(i);
请帮帮我,我有点卡住了
从API文档:
公共抽象文件getCacheDir()
返回文件系统上应用程序特定的缓存目录的绝对路径。
(强调我的)
getCacheDir()
返回的目录只能由您的应用程序读取,请改用getExternalCacheDir()
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.