开发者

Using ACTION_SEND with Bluetooth

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 go开发者_StackOverflowtchas 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);
}


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜