Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/file/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在android中使用默认蓝牙应用程序发送文件_Android_File_Bluetooth_File Transfer - Fatal编程技术网

在android中使用默认蓝牙应用程序发送文件

在android中使用默认蓝牙应用程序发送文件,android,file,bluetooth,file-transfer,Android,File,Bluetooth,File Transfer,我想使用Android应用程序将文件从我的手机发送到其他手机。该文件的类型为“.Xcard”。我想使用android环境提供的默认蓝牙应用程序。也就是说,当我单击send时,默认的应用程序选择器应该打开,然后我应该能够通过选择设备将文件发送到其他设备。 我该怎么做?文件可能是空的,也可能不是空的 我尝试了以下代码,但它不起作用。我收到一条祝酒词,上面写着:“文件未发送” 请帮帮我,我被API文档卡住了: 公共抽象文件getCacheDir() 返回文件系统上特定于应用程序的缓存目录的绝对路径 (

我想使用Android应用程序将文件从我的手机发送到其他手机。该文件的类型为“.Xcard”。我想使用android环境提供的默认蓝牙应用程序。也就是说,当我单击send时,默认的应用程序选择器应该打开,然后我应该能够通过选择设备将文件发送到其他设备。 我该怎么做?文件可能是空的,也可能不是空的

我尝试了以下代码,但它不起作用。我收到一条祝酒词,上面写着:“文件未发送”

请帮帮我,我被API文档卡住了

公共抽象文件getCacheDir()

返回文件系统上特定于应用程序的缓存目录的绝对路径

(强调矿山)

getCacheDir()
返回的目录只能由应用程序读取,请改用
getExternalCacheDir()

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