J2ME

Discover remote bluetooth devices MIDlet

0

going from the previous sample
discover-remote-bluetooth-devices
we are now going to make an advanced sample

we want MIDlet Application that can turn on/off Bluetooth discovery, and can make a search for devices and can stop the search any time

we need some attributes like a refrence to the local device and the discovery agent and a vector to store the discovered remote devices in.

also we will need commands to turn on/off discovery and one to start searching and another to stop it.

our class implements DiscoveryListener interface to listen to the actions generated by DiscoveryAgent
also it implements CommandListener to listen to the events of commands

(more…)

Discover Remote bluetooth devices

3

To make a useful bluetooth client in J2ME it’s important to discover remote devices
first thing in making any bluetooth-enabled application is to get a reference to the Local device and after that turning on the bluetooth

        LocalDevice localDevice;
        try {
            localDevice = LocalDevice.getLocalDevice();
            localDevice.setDiscoverable(DiscoveryAgent.GIAC);
        } catch (BluetoothStateException ex) {
            ex.printStackTrace();
        }

(more…)

Simple bluetooth connection

0


A sample code to make a connection between two cell phones using Bluetooth connection

the required libraries we must import in the first

import java.io.*;
import javax.bluetooth.*;
import javax.microedition.io.*;

(more…)

Load Images using J2ME

3
image

image

in j2me we create th image using Imgae.createImage method
on of the overloaded constructrs takes an InputStream object

to get an InputStram from an HTTP resource we make a connection using GCF by passing the url to the Connector.open method
(more…)

insert a button in a form in J2ME

1

there is no Button component in LCDUI components
so we must do it with our hands
we can make use of CustomItem by extending it and drawing the button with our hands

we can implement an interface with only one method that executed when we press on the button
(more…)

SMS

send SMS using J2ME

0
SMS

SMS

a simple code to send an SMS message using J2ME
you should put that code in a thread if you don’t want to block your application

we use the General Connection Framwork (GCF)
we use the Connector.open method and pass an sms address
(more…)

csv

Parsing CSV file in J2ME

0
csv

csv

the CSV file is asimple lightweight replicant of the database
it can hold table information and it can be processed easily through java

example of our data table or database

Egypt      Cairo       Africa
France     Paris       Europe
England    London    Europe
Iraq         Baghdad  Asia

(more…)

xml

Parsing XML in J2ME using KXML

1
xml

xml file

to read an XML file
we first nead to import KXML and th i/0 libraries

import org.kxml.kdom.*;
import org.kxml.parser.XmlParser;
import java.io.*;
import javax.microedition.io.*;

(more…)

Go to Top