Skip to main content

J2me Limitations in Windows Mobile

2 replies [Last post]
praveen0922
Offline
Joined: 2009-08-11

What are the APIs (JSR) in J2ME will support for windows mobile. Could any one know please help..

I want to find out Location API (JSR 179) in j2me will support windows mobile 6 or not..

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
praveen0922
Offline
Joined: 2009-08-11

The below code i have written for test GPS in windows mobile HTC, using Esmertec Jbed 20090217.5.1R2.cab to test. The application not get any error. Every time am getting the invalid location like(Latitude 0.0 ,Longitude 0.0 ).

If i opened the google maps and came back to my application in HTC TY TN II it return values up to 5 to 10 mimes. Does any one now is there is any problem with the code or any other.

My thinking is my when i run my j2me application its not triggering to get the information from satellite, Its just returns the information from the GPS Driver .

Does any one knows how to fix this issue..please help me..

package com.gps;

import java.util.Timer;
import java.util.TimerTask;
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.lcdui.StringItem;
import javax.microedition.location.Location;
import javax.microedition.location.LocationException;
import javax.microedition.location.LocationProvider;
import javax.microedition.location.QualifiedCoordinates;
import javax.microedition.midlet.MIDlet;
import javax.microedition.midlet.MIDletStateChangeException;

public class TestGps extends MIDlet implements CommandListener {

private Display display;
private Form form;
public StringItem si;
private Command cmdExit, cmdOK;
public LocationProvider _locationProvider = null;
public Timer updateTimer = new Timer();

public TestGps() {

display = Display.getDisplay(this);

form = new Form("Location Test");

cmdExit = new Command("Exit", Command.EXIT, 2);
cmdOK = new Command("OK", Command.OK, 1);
si = new StringItem("Geo Location", null);
form.append(si);
//getLocation();
// GPSTimer gPSTimer=new GPSTimer();
// updateTimer.schedule(gPSTimer,0, 500);
form.addCommand(cmdOK);
form.addCommand(cmdExit);

form.setCommandListener(this);

}

public void displayString(String string) {
si.setText(string);
}

protected void destroyApp(boolean unconditional) throws MIDletStateChangeException {
notifyDestroyed();
}

protected void pauseApp() {
}

protected void startApp() {
display.setCurrent(form);
}

public void commandAction(Command c, Displayable d) {

if (c == cmdOK) {
// GPSThread gPSThread=new GPSThread();
//gPSThread.start();
// getLocation();
form.removeCommand(cmdOK);
GPSTimer gPSTimer = new GPSTimer();
updateTimer.schedule(gPSTimer, 0, 1000 * 20);
}
if (c == cmdExit) {
try {
destroyApp(false);
} catch (MIDletStateChangeException ex) {
ex.printStackTrace();
}
}
}

public void updateLocation() {
try {

Location lp = null;

// if(gpsValue){
// _locationProvider.setLocationListener(null, -1, -1, -1);
// gpsValue=false;
// }

if (_locationProvider == null) {
_locationProvider = LocationProvider.getInstance(null);
}
try {
lp = _locationProvider.getLocation(400);

} catch (InterruptedException ex) {
ex.printStackTrace();
} catch (LocationException ex) {
ex.printStackTrace();
}
QualifiedCoordinates cord = lp.getQualifiedCoordinates();
int locmeth=lp.getLocationMethod();
form.append(Integer.toString(locmeth));
//DONT REMOVE THIS LOG

if (lp.isValid()) {
System.out.print("Latitude: " + cord.getLatitude() + " Longitude : " + cord.getLongitude() +
" Altitude : " + cord.getAltitude());
form.append("Latitude: " + cord.getLatitude() + " Longitude :" + cord.getLongitude() + " Altitude:" + cord.getAltitude());

} else {
form.append("location is invalid");
System.out.print("location is invalid");
}

} catch (LocationException ex) {
ex.printStackTrace();
}

}

private class GPSTimer extends TimerTask {

public void run() {
updateLocation();
}
}

}

Terrence Barr - Senior Technologist and Ambassador

It depends on which Java ME stack you are referring to.

For phoneME Advanced you can find the list of implemented JSRs here

https://phoneme.dev.java.net/content/phoneme_advanced_r2.html

For the JavaFX Mobile 1.2 EA release for Windows Mobile you can
find the list of JSRs in the Release Notes:

http://javafx.com/downloads (click on the "JavaFX Mobile" bundle)

You also may have a Java ME stack from a different vendor already
installed on you Windows Mobile device, for example JBlend by
Esmertec. Consult their documentation for details.

Hope that helps,

-- Terrence

meappdev-interest@mobileandembedded.org wrote:
> What are the APIs (JSR) in J2ME will support for windows mobile. Could any one know please help..
>
> I want to find out Location API (JSR 179) in j2me will support windows mobile 6 or not..
> [Message sent by forum member 'praveen0922' (praveen0922)]
>
> http://forums.java.net/jive/thread.jspa?messageID=360065
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: interest-unsubscribe@meapplicationdevelopers.dev.java.net
> For additional commands, e-mail: interest-help@meapplicationdevelopers.dev.java.net
>
>
[terrence_barr.vcf]
---------------------------------------------------------------------
To unsubscribe, e-mail: interest-unsubscribe@meapplicationdevelopers.dev.java.net
For additional commands, e-mail: interest-help@meapplicationdevelopers.dev.java.net