用这个profile之前,要确保oppservice启动,在在BluetoothOppProvider的public Uri insert(Uri uri, ContentValues values) 方法中去启动。OPP可用来发送文件,也可用接收文件,这篇日志记录简单的opp发送文件和接收文件的过程。
手机发送文件,其他模块调用ChooserActivity,创建出共享的dialog。选择用蓝牙发送,将启动BluetoothOppLauncherActivity,在搜索完设备选择了一个设备后:
1)调用DevicePickerFragment类里的sendDevicePickedIntent方法,将BluetoothDevicePicker.ACTION_DEVICE_SELECTED广播给BluetoothOppReceiver处理:
// Insert transfer session record to database
mOppManager.startTransfer(remoteDevice);
BluetoothOppManager调用内部类InsertShareInfoThread将发送的文件加入数据库的线程启动。文件加入DB后,将由BluetoothOppProvider向其他APP提供数据。
code: insertSingleShare()
{
final Uri contentUri = mContext.getContentResolver().insert(BluetoothShare.CONTENT_URI,values);
}
监听数据库变化的:
mObserver = new BluetoothShareContentObserver();
&n

本文详细介绍了蓝牙OPP(对象推送协议)在文件发送和接收过程中的工作原理。首先,确保OPP服务已启动,然后通过BluetoothOppManager和BluetoothOppReceiver处理发送文件的流程,包括启动发送线程、建立连接和进行OBEX会话。接收文件时,BluetoothServerSocket监听连接请求,用户确认后启动接收线程,处理数据库更新和文件存储。整个过程中涉及到蓝牙连接、数据库操作和用户交互。

240

被折叠的 条评论
为什么被折叠?



