我正在写蓝牙客户端,我有一个问题.我的第一个活动显示在ListView中启用了设备.单击此列表中的某个项目时,它应该启动新活动并在那里传递BluetoothDevice对象.我写的是这样的:
public void onItemClick(AdapterView<?> parent, View view, int position,
long id) {
// TODO Auto-generated method stub
if(btAdapter.isDiscovering()) {
btAdapter.cancelDiscovery();
}
if(listAdapter.getItem(position).contains("Paired")) {
BluetoothDevice selectedDevice = devices.get(position);
Intent intent = new Intent (this, BTActivity.class);
intent.putExtra("btdevice", selectedDevice);
startActivity(intent);
Run Code Online (Sandbox Code Playgroud)
是否可以将BluetoothDevice对象传递给另一个活动?如何在新活动中提取此对象?
对不起我的英语不好.如果事情不明确,我会尝试更好地解释.