Home | Русский

J2ME e-mail validator

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;
[...]

Posted in: J2ME by admin No Comments , , ,

How to create a Gauge Tracker

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;

[...]

Posted in: J2ME by admin No Comments ,

How to Send an HTTP POST and GET Requests

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);
}
[...]

Posted in: J2ME by admin No Comments , , ,

J2ME – How to write – read image in – from RMS

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 [...]

Posted in: J2ME by admin No Comments , , , ,

RecordStore(rms) write Java Object

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 [...]

Finding multimedia content-type support of a mobile device

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 [...]

Posted in: J2ME by admin No Comments , , ,

How to use ChoiceGroup in J2ME

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;
[...]

Posted in: J2ME by admin No Comments , ,

Validate the size of a TextField

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 = [...]

Posted in: J2ME by admin No Comments , ,

Detect Bluetooth API optional package (JSR 82)

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 [...]

Posted in: J2ME by admin No Comments , , ,

J2ME – Images, Tickers and Gauges

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 [...]

Posted in: J2ME by admin 1 Comment , , , ,