| Reply | « Previous Thread | Next Thread » |
|
Hey first time post, I was looking for some help.
![]() I've written myself a MIDP application and I want it to be able to connect to the same app on other devices using bluetooth. I would like my devices to "PAIR" (pairing should allow connection without user acceptance from the 2nd time onwards?) I then want it to exchange about four strings so pretty easy communication you'd think. I can show a list of available devices in my midp with the following code Firstly it finds the devices and counts them up Code:
public void deviceDiscovered(RemoteDevice remoteDevice, DeviceClass deviceClass) //find devices add them to a vector
{
devices.addElement(remoteDevice);
Form form = new Form( "Searching" );
form.append( "Found " + Integer.toString(devices.size()).toString() + " devices" );
Display.getDisplay(this).setCurrent( form );
}
Code:
public void inquiryCompleted(int discoveryType) //Print devices found
{
devices.trimToSize();
/* create a list widget */
List chooseList = new List( Integer.toString(devices.size()).toString() + " devices", List.IMPLICIT );
try
{
int i;
for(i = 0; i < devices.size(); i++) {
RemoteDevice d = (RemoteDevice)devices.elementAt(i);
chooseList.set(i, d.getFriendlyName(false), null);
}
mBackCommand = new Command("Back", Command.BACK, 0);
chooseList.addCommand(mBackCommand);
chooseList.setCommandListener(new CommandListener()
{public void commandAction(Command mBackCommand, Displayable s){display.setCurrent(mList);
}});
}
catch (Exception e)
{
System.out.println(e);
}
}
Any and all help is much appreciated Paul ![]() p.s. sorry if i've conveyed myself poorly, found it a bit tricky to explain, any querys i'll try to answer to inform you more |
| Reply | « Previous Thread | Next Thread » |
| Thread Tools | Search this Thread |
|---|---|