android - Passing BluetoothDevice Object to Another Activity though Intent -
i'm writing bluetooth client , have problem. first activity display enabled devices in listview. when click on item on list, should start new activity , pass bluetoothdevice object there. write that:
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);
is possible pass bluetoothdevice object activity? how extract object in new activity?
sorry english. if isn't clear, try explain better.
yes . possible since bluetoothdevice
class implements
parcelable
you can object in other activity
this
bluetoothdevice bluetoothdevice = getintent().getextras().getparcelable("btdevice");
make sure getintent().getextras() not null
Comments
Post a Comment