2017-02-14 119 views
-1

我正在通過Bluetooth共享文件。文件已成功發送,但問題是我無法收到文件完全發送時的任何事件。我已經加入接收機AndroidManifest.xml作爲無法接收BluetoothOppLauncherActivity廣播事件

<receiver android:name=".FileSentReceiver" 
      android:exported="true"> 
      <intent-filter > 
       <action android:name="android.btopp.intent.action.TRANSFER_COMPLETE"/> 
      </intent-filter> 
</receiver> 

和代碼共享文件如下:

File file = new File(Environment.getExternalStorageDirectory() + "/Download/file_to_sent.txt"); 
Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND); 
       sharingIntent.setType("text/plain"); 
       sharingIntent.setComponent(new ComponentName("com.android.bluetooth", "com.android.bluetooth.opp.BluetoothOppLauncherActivity")); 
       sharingIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(file)); 
       startActivity(sharingIntent); 

我怎樣才能收到文件的完整/下降的事件?

回答

0

實際上,您需要爲ACTION_BT_OPP_TRANSFER_DONE註冊一個BroadcastReceiver,然後檢查EXTRA_BT_OPP_TRANSFER_STATUS多餘的,看看它是成功還是失敗。

看起來這些似乎不屬於公共API &,這可能會在未來版本中發生變化。

詳見here

+0

我嘗試了這些事件,但仍無法收到,它看起來這些事件不能從其他應用程序接收。 –