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;
}
int emailLenght = email.length();
int atPosition = email.indexOf("@");
String beforeAt = email.substring(0, atPosition);
String afterAt = email.substring(atPosition + 1, emailLenght);
if (beforeAt.length() == 0 ||
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;
public GaugeTracker() {
int initialValue = 3;
mGauge = new Gauge("GaugeTitle", true, 5, initialValue);
mStringItem = new StringItem(null,
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);
}
String result = Connect.getInstance().getResult();
}
[/]
[ lang="java"
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 display = null;
private static
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 a unique identifier, an integer called the record ID. The first record added to a record store has a record ID of 1, the second a recor
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
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.microedit
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 C
Published at: 07:11 am - Friday November 21 2008
Today's sample code will implement very similar UI to the one created in the LinearLayout Example. But here we will be using a TableLayout widget instead.
Each TableLayout consists of a number of TableRow objects and each TableRow object contains zero or more cells. Each cell can hold one View object. The table has as many columns as the row with the most cells and cells can of course span columns. Here is a simple example of a "Sign In" form created with the TableLayout container:
< ?x
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