无法接收BluetoothOppLauncherActivity广播事件
问题描述:
我正在通过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);
我怎样才能收到文件的完整/下降的事件?
答
实际上,您需要为ACTION_BT_OPP_TRANSFER_DONE
注册一个BroadcastReceiver,然后检查EXTRA_BT_OPP_TRANSFER_STATUS
多余的,看看它是成功还是失败。
看起来这些似乎不属于公共API &,这可能会在未来版本中发生变化。
详见here
我尝试了这些事件,但仍无法收到,它看起来这些事件不能从其他应用程序接收。 –