nee*_*rle 5 android intentfilter android-manifest mime-types
我确实需要帮助来解决此问题:
我正在开发一个应用程序,以使用蓝牙将文件从应用程序传输到其他手机。当我想传输图像文件时,代码的一部分如下:
intent.setType("image/*");
i.putExtra(i.EXTRA_STREAM, uri);
//here uri has the URI of the image that I want to send.
Run Code Online (Sandbox Code Playgroud)
android清单文件如下:
<intent-filter>
<action android:name="android.intent.action.MAIN"
<category android:name="android.intent.category.LAUNCHER" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="file" />
<data android:mimeType="image/*" />
<data android:host="*" />
</intent-filter>
Run Code Online (Sandbox Code Playgroud)
和代码工作正常。现在我的问题是:同样,我想发送一个由以下行创建的文件:
f = File.createTempFile("card", ".XCard", getExternalCacheDir());
Run Code Online (Sandbox Code Playgroud)
该文件的名称应如下所示:
card12434247.Xcard
Run Code Online (Sandbox Code Playgroud)
现在,我在上面发布的代码中需要进行哪些修改?我应该如何在intent-filter中编写mimeType?
应该是什么行:
intent.setType(...)?
Run Code Online (Sandbox Code Playgroud)
我应该如何修改它以便蓝牙能够处理此文件
xyz.Xcard ??
Run Code Online (Sandbox Code Playgroud)
我应该如何声明通过蓝牙发送文件时需要的自定义mime类型?需要吗?请帮忙!!
尝试将文件放在蓝牙目录中,它对我有用。
String root = Environment.getExternalStorageDirectory().toString();
Intent i = new Intent(Intent.ACTION_SEND);
i.setType("text/html");
File f = new File(root + "/bluetooth/test2.html");
i.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(f));
startActivity(Intent.createChooser(i, "Send page"));
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2596 次 |
| 最近记录: |