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; } 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 ||
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; public GaugeTracker() { int initialValue = 3; mGauge = new Gauge("GaugeTitle", true, 5, initialValue); mStringItem = new StringItem(null,
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); } String result = Connect.getInstance().getResult(); } [/] [ lang="java"
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 display = null; private static
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 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

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
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.microedit
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 C
Posted in: J2ME by admin No Comments , ,

Android - TableLayout Samples

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
Posted in: Android 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
Posted in: J2ME by admin No Comments , , ,