Published at: 04:06 am - Thursday June 25 2009
Simple email validator in j2me.
public static boolean validate(String email) {
if (email == null || email.length() == 0 || email.indexOf(”@”) == -1 || email.indexOf(” “) != -1) {
return false;
[...]
Published at: 06:01 am - Friday January 23 2009
This example shows how to create a Gauge tracker in MIDP.
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
public class GaugeTracker extends MIDlet
implements ItemStateListener, CommandListener {
private Gauge mGauge;
private StringItem mStringItem;
[...]
Published at: 06:01 am - Friday January 23 2009
As you might imagine, sending an HTTP POST request is a very similar process to sending a GET request.
See example.
public void httpRequest(){
Connect.getInstance().setParam(”all”, “getall”));
Connect.getInstance().setParam(”sessionid”, “64654sdf465sadf4″);
Connect.getInstance().doPost(”http://freesrc.com/”);
while (Connect.getInstance().isActive()) {
Thread.sleep(20);
}
[...]
Published at: 02:01 am - Monday January 05 2009
The example below saves image file into RMS and shows it on mobile.
Data like image, image name, width, height can be stored in RMS.
The size of the image file do matters if phone capacity is small.
Sample.java
package freesrc.com;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Image;
import javax.microedition.midlet.*;
/**
* @author freesrc.com
*/
public class Sample extends MIDlet {
private Display [...]
Published at: 04:12 am - Thursday December 18 2008
A record store is an ordered collection of records. Records are not independent entities: each must belong to a record store, and all record access occurs through the record store. In fact, the record store guarantees that records are read and written atomically, with no possibility of data corruption.
When a record is created, the record store assigns it [...]
Published at: 05:11 am - Monday November 24 2008
MMAPI gives facility of playing audio/video on mobile phones. MMAPI’s content-type/protocol support depends upon the mobile device capabilities.
The example below displays the mulitmedia file formats that are supported on a mobile phone:
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
import javax.microedition.media.Manager;
public class Midlet extends MIDlet implements CommandListener {
private static final Command exit = new Command(”Exit”, Command.EXIT, 0);
private static final Command detail [...]
Published at: 05:11 am - Monday November 24 2008
This J2ME tips illustrates method of using a ChoiceGroup in mobile applications.
ChoiceGroup is a group of selectable elements intended to be placed within a Form.
import javax.microedition.lcdui.Choice;
import javax.microedition.lcdui.ChoiceGroup;
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.Form;
import javax.microedition.midlet.*;
public class Midlet extends MIDlet implements CommandListener {
private Display display;
private Form form;
[...]
Published at: 02:11 am - Monday November 24 2008
import com.planstick.business.User;
import com.planstick.event.PlanStickEvent;
import com.planstick.event.PlanStickEventListener;
import com.planstick.main.OC;
import com.planstick.net.Session;
import com.planstick.utils.Record;
import javax.microedition.lcdui.*;
public class LoginSettings extends Form implements CommandListener{
private TextField pasw = null;
private TextField login = null;
private Command save = new Command(”Save”, Command.OK, 0);
private Command back = new Command(”Back”, Command.BACK, 1);
private Command ok = new Command(”OK”, Command.ITEM, 1);
public LoginSettings(User user) {
super(”");
if(user == null){
login = new TextField(”Login:”, “”, 30, TextField.ANY);
pasw = [...]
Published at: 06:11 am - Friday November 21 2008
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
public class MMain extends MIDlet implements CommandListener
{
private Form form;
// Check if Bluetooth API optional package (JSR 82) is present.
public static boolean hasBluetoothAPI ()
{
try
{
Class.forName (”javax.bluetooth.LocalDevice”);
return true;
}
catch (Exception _ex)
{
return false;
}
}
// Return the Bluetooth API version of this device, null if API is not present…
public static String verBluetoothAPI ()
{
// Initialize return value…
String version = null;
// First [...]
Published at: 08:11 am - Thursday November 20 2008
Using images, tickers, and gauges as UI elements in MIDlets is quite straightforward. A gauge, as you saw in the last section, is an item that can only be displayed on a form to indicate progress or to control a MIDlet feature (like volume). A ticker, on the other hand, can be attached to any [...]