通过蓝牙使用 ACTION_SEND
我使用带有 ACTION_SEND
和 EXTRA_STREAM
的 Android Intent
通过 ContentProvider
共享生成的 PNG。这对于电子邮件/GMail、Flickr、MMS 等非常有效,但如果我从活动选择器对话框中选择蓝牙,则不起作用。
该设备是运行 Android 2.1 的 HTC Legend。该设备能够正常通过蓝牙与我的计算机共享图像,只是在我的应用程序调用时无法共享图像。我收到一条包含以下文本的祝酒消息:
蓝牙共享:文件未知文件未发送
logcat 输出的信息不是特别丰富。唯一的错误级别条目如下,它似乎在调用我的 ContentProvider
的 query
方法后立即发生(该方法本身由 openFileHelper
调用)代码>方法)。没有堆栈跟踪。
E/BluetoothOppSendFileInfo( 337): scheme: content, authority: mydomain.myapp.myprovider
我已经搜索了Android蓝牙源代码并且我找不到这条无信息的日志消息的写入位置。
也许我的 ContentProvider
有问题,但我不知道它对其他 Intent 目标有何作用。
有人知道我可能不知道的任何蓝牙特定问题吗?
就其价值而言,我的 ContentProvider
如下所示:
@Override
public Cursor query(Uri uri,
String[] projection,
String selection,
String[] selectionArgs,
String sortOrder)
{
if (uri.equals(CONTENT_URI))
{
String[] columns = projection == null
? new String[]{"uri", "mime_type", "_data"}
: projection;
MatrixCursor cursor = new MatrixCursor(columns);
cursor.addRow(getColumns(columns));
return cursor;
}
throw new IllegalArgumentException("Unsupported URI");
}
@Override
public ParcelFileDescriptor openFile(Uri uri,
String mode) throws FileNotFoundException
{
return openFileHelper(uri, mode);
}
I am using an Android Intent
with ACTION_SEND
and EXTRA_STREAM
to share a generated PNG via a ContentProvider
. This works perfectly for e-mail/GMail, Flickr, MMS, etc. but doesn't work if I select Bluetooth from the activity chooser dialog.
The device is an HTC Legend running Android 2.1. The device is able to share images with my computer over Bluetooth normally, just not when invoked by my app. I get a toast message with the following text:
Bluetooth share: File Unknown file not sent
The logcat output is not particularly informative. The only error level entry is the following, which appears to happen immediately after the query
method of my ContentProvider
is called (which itself is invoked by the openFileHelper
method). There is no stacktrace.
E/BluetoothOppSendFileInfo( 337): scheme: content, authority: mydomain.myapp.myprovider
I have searched through the Android Bluetooth source code and I cannot find where this uninformative log message is written.
Perhaps there is something wrong with my ContentProvider
, but I don't know what seeing as it works for the other Intent targets.
Is anybody aware of any Bluetooth-specific gotchas that I may be ignorant of?
For what it's worth, here's what my ContentProvider
looks like:
@Override
public Cursor query(Uri uri,
String[] projection,
String selection,
String[] selectionArgs,
String sortOrder)
{
if (uri.equals(CONTENT_URI))
{
String[] columns = projection == null
? new String[]{"uri", "mime_type", "_data"}
: projection;
MatrixCursor cursor = new MatrixCursor(columns);
cursor.addRow(getColumns(columns));
return cursor;
}
throw new IllegalArgumentException("Unsupported URI");
}
@Override
public ParcelFileDescriptor openFile(Uri uri,
String mode) throws FileNotFoundException
{
return openFileHelper(uri, mode);
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
将 HTC Legend 手机升级到 Android 2.2 (Froyo) 后,问题消失了,这表明该手机软件的先前版本的蓝牙支持存在问题。
After upgrading the HTC Legend handset to Android 2.2 (Froyo), the problem has gone away, which suggests there was something faulty in the Bluetooth support in the previous version of the phone's software.