2013-02-10 94 views
2

我試圖使用來自galaxy nexus(運行4.2.1)的setBeamPushUrisCallback到nexus7(運行4.2)的內容提供者uri。無論是設備安裝該應用,但NFC切換期間的傳輸失敗到藍牙,我得到的例外是:Android Beam ContentProvider Uri失敗

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 

我宣佈我的清單提供者(我可以查詢URI只是罰款我應用程序),並添加意圖過濾器,以便在梁成功時啓動該活動。我究竟做錯了什麼?爲什麼切換到藍牙總是不是wifi?

更新:

這裏是從應用程序相關的代碼:

活性實現CreateBeamUrisCallback和在OnCreate:

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

和重寫的方法:

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

清單:

<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> 
+0

你能否展示你的應用的一些相關代碼? (Android Beam始終使用藍牙,目前不支持WiFi,這與三星S-Beam相反,三星S-Beam始終使用WiFi Direct,但僅適用於最新的Samsung NFC設備。) – 2013-02-11 15:18:15

+0

感謝您的澄清!我用一段代碼更新了我的問題。 – 2013-02-11 15:49:13

回答

0

我發現這個問題,我在我的內容提供商,在那裏我有查詢數據庫,從遊標檢索值,並寫入文件和文件返回ParcelFileDescriptor覆蓋openFile(Uri uri, String mode)