Question

Am trying to beam a content provider uri using setBeamPushUrisCallback from galaxy nexus (running 4.2.1) to nexus7 (running 4.2). Both the devices have the app installed, but the transfer fails during the NFC handover to bluetooth, the exception I get is:

02-10 13:33:32.762: D/BluetoothOppUtility(23916): closeSendFileInfo:  uri=content://com.android.beam.Beam/msgs/2
02-10 13:33:32.762: W/dalvikvm(23916): threadid=21: thread exiting with uncaught exception (group=0x40d70930)
02-10 13:33:32.770: E/AndroidRuntime(23916): FATAL EXCEPTION: Bluetooth Share Service
02-10 13:33:32.770: E/AndroidRuntime(23916): java.lang.NullPointerException
02-10 13:33:32.770: E/AndroidRuntime(23916):    at com.android.bluetooth.opp.BluetoothOppUtility.closeSendFileInfo(BluetoothOppUtility.java:327)
02-10 13:33:32.770: E/AndroidRuntime(23916):    at com.android.bluetooth.opp.BluetoothOppService.insertShare(BluetoothOppService.java:614)
02-10 13:33:32.770: E/AndroidRuntime(23916):    at com.android.bluetooth.opp.BluetoothOppService.access$1800(BluetoothOppService.java:69)
02-10 13:33:32.770: E/AndroidRuntime(23916):    at com.android.bluetooth.opp.BluetoothOppService$UpdateThread.run(BluetoothOppService.java:472)
02-10 13:33:32.941: E/NfcHandover(693): Handover transfer failed

I have declared the provider in my manifest(I could query the uri just fine in my application) and added the intent filter for the activity to be launched when the beam succeeds. What am I doing wrong? and why is the handover done to bluetooth always and not wifi?

Update:

Here is the relevant piece of code from the app:

The activity implements CreateBeamUrisCallback and in the onCreate:

 mNfcAdapter = NfcAdapter.getDefaultAdapter(this);
 if (mNfcAdapter == null) return;  // NFC not available on this device
 mNfcAdapter.setBeamPushUrisCallback(this, this);

and overridden method:

@Override
public Uri[] createBeamUris(NfcEvent event) {
    Uri uri = Uri.parse("content://com.android.beam.Beam/msgs/2");
    return new Uri[]{uri};
}

Manifest:

 <provider
    android:name="com.example.android.beam.BeamContentProvider"
    android:authorities="com.android.beam.Beam"
    android:exported="true"/>
 <activity android:name="com.example.android.beam.Beam"
            android:label="@string/app_name"
            android:launchMode="singleTop">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
         <intent-filter>
             <action android:name="android.intent.action.VIEW" />
            <action android:name="android.intent.action.EDIT" />
            <action android:name="android.intent.action.PICK" />
            <category android:name="android.intent.category.DEFAULT" />
            <data android:mimeType="vnd.android.cursor.item/vnd.com.example.msgs" />
        </intent-filter>
    </activity>
Was it helpful?

Solution

I found the problem, I had to override openFile(Uri uri, String mode) in my Content Provider, where I had to query the database, retrieve the values from the cursor, write them to a file and return the ParcelFileDescriptor for the file.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top