السلام عليكم
كيف أرسل رسالة بلوتوث
مثلا:
إرسال بايتات
أرقام
ملفات
-----------------------------------------------
أرجو الرد السريع وشكرا
السلام عليكم
كيف أرسل رسالة بلوتوث
مثلا:
إرسال بايتات
أرقام
ملفات
-----------------------------------------------
أرجو الرد السريع وشكرا
أنا جالس أبحث فيث الموضوع وإن شاء الل أرد لك قريب
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
import javax.bluetooth.RemoteDevice;
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
import javax.microedition.pim.PIM;
import org.netbeans.microedition.lcdui.pda.PIMBrowser;
/**
* @author Eyas
*/
public class bluetoothex extends MIDlet implements CommandListener {
private boolean midletPaused = false;
RemoteDevice rmd;
//<editor-fold defaultstate="collapsed" desc=" Generated Fields ">
private Form form;
private List list;
private PIMBrowser pimBrowser;
private List list1;
private Command okCommand;
//</editor-fold>
/**
* The bluetoothex constructor.
*/
public bluetoothex() {
}
//<editor-fold defaultstate="collapsed" desc=" Generated Methods ">
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc=" Generated Method: initialize ">
/**
* Initilizes the application.
* It is called only once when the MIDlet is started. The method is called before the <code>startMIDlet</code> method.
*/
private void initialize() {
// write pre-initialize user code here
// write post-initialize user code here
}
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc=" Generated Method: startMIDlet ">
/**
* Performs an action assigned to the Mobile Device - MIDlet Started point.
*/
public void startMIDlet() {
// write pre-action user code here
switchDisplayable(null, getForm());
// write post-action user code here
}
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc=" Generated Method: resumeMIDlet ">
/**
* Performs an action assigned to the Mobile Device - MIDlet Resumed point.
*/
public void resumeMIDlet() {
// write pre-action user code here
// write post-action user code here
}
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc=" Generated Method: switchDisplayable ">
/**
* Switches a current displayable in a display. The <code>display</code> instance is taken from <code>getDisplay</code> method. This method is used by all actions in the design for switching displayable.
* @param alert the Alert which is temporarily set to the display; if <code>null</code>, then <code>nextDisplayable</code> is set immediately
* @param nextDisplayable the Displayable to be set
*/
public void switchDisplayable(Alert alert, Displayable nextDisplayable) {
// write pre-switch user code here
Display display = getDisplay();
if (alert == null) {
display.setCurrent(nextDisplayable);
} else {
display.setCurrent(alert, nextDisplayable);
}
// write post-switch user code here
}
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc=" Generated Method: commandAction for Displayables ">
/**
* Called by a system to indicated that a command has been invoked on a particular displayable.
* @param command the Command that was invoked
* @param displayable the Displayable where the command was invoked
*/
public void commandAction(Command command, Displayable displayable) {
// write pre-action user code here
if (displayable == form) {
if (command == okCommand) {
// write pre-action user code here
switchDisplayable(null, getPimBrowser());
// write post-action user code here
}
} else if (displayable == list) {
if (command == List.SELECT_COMMAND) {
// write pre-action user code here
listAction();
// write post-action user code here
}
} else if (displayable == list1) {
if (command == List.SELECT_COMMAND) {
// write pre-action user code here
list1Action();
// write post-action user code here
}
} else if (displayable == pimBrowser) {
if (command == PIMBrowser.SELECT_PIM_ITEM) {
// write pre-action user code here
// write post-action user code here
}
}
// write post-action user code here
}
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc=" Generated Getter: form ">
/**
* Returns an initiliazed instance of form component.
* @return the initialized component instance
*/
public Form getForm() {
if (form == null) {
// write pre-init user code here
form = new Form("form");
form.addCommand(getOkCommand());
form.setCommandListener(this);
// write post-init user code here
}
return form;
}
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc=" Generated Getter: list ">
/**
* Returns an initiliazed instance of list component.
* @return the initialized component instance
*/
public List getList() {
if (list == null) {
// write pre-init user code here
list = new List("list", Choice.IMPLICIT);
list.setCommandListener(this);
// write post-init user code here
// rmd= new RemoteDevice();
}
return list;
}
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc=" Generated Method: listAction ">
/**
* Performs an action assigned to the selected list element in the list component.
*/
public void listAction() {
// enter pre-action user code here
String __selectedString = getList().getString(getList().getSelectedIndex());
// enter post-action user code here
}
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc=" Generated Getter: okCommand ">
/**
* Returns an initiliazed instance of okCommand component.
* @return the initialized component instance
*/
public Command getOkCommand() {
if (okCommand == null) {
// write pre-init user code here
okCommand = new Command("Ok", Command.OK, 0);
// write post-init user code here
}
return okCommand;
}
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc=" Generated Getter: pimBrowser ">
/**
* Returns an initiliazed instance of pimBrowser component.
* @return the initialized component instance
*/
public PIMBrowser getPimBrowser() {
if (pimBrowser == null) {
// write pre-init user code here
pimBrowser = new PIMBrowser(getDisplay(), PIM.CONTACT_LIST);
pimBrowser.setTitle("pimBrowser");
pimBrowser.addCommand(PIMBrowser.SELECT_PIM_ITEM);
pimBrowser.setCommandListener(this);
// write post-init user code here
}
return pimBrowser;
}
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc=" Generated Getter: list1 ">
/**
* Returns an initiliazed instance of list1 component.
* @return the initialized component instance
*/
public List getList1() {
if (list1 == null) {
// write pre-init user code here
list1 = new List("list1", Choice.IMPLICIT);
list1.setCommandListener(this);
// write post-init user code here
}
return list1;
}
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc=" Generated Method: list1Action ">
/**
* Performs an action assigned to the selected list element in the list1 component.
*/
public void list1Action() {
// enter pre-action user code here
String __selectedString = getList1().getString(getList1().getSelectedIndex());
// enter post-action user code here
}
//</editor-fold>
/**
* Returns a display instance.
* @return the display instance.
*/
public Display getDisplay () {
return Display.getDisplay(this);
}
/**
* Exits MIDlet.
*/
public void exitMIDlet() {
switchDisplayable (null, null);
destroyApp(true);
notifyDestroyed();
}
/**
* Called when MIDlet is started.
* Checks whether the MIDlet have been already started and initialize/starts or resumes the MIDlet.
*/
public void startApp() {
if (midletPaused) {
resumeMIDlet ();
} else {
initialize ();
startMIDlet ();
}
midletPaused = false;
}
/**
* Called when MIDlet is paused.
*/
public void pauseApp() {
midletPaused = true;
}
/**
* Called to signal the MIDlet to terminate.
* @param unconditional if true, then the MIDlet has to be unconditionally terminated and all resources has to be released.
*/
public void destroyApp(boolean unconditional) {
}
}