GPS on MOT i415 - to server?

I am trying to find some help on getting started with this project. Would like to simply read the GPS data from the built in GPS on the i415 phone and send this data to a server. For some reason I cannot find anyone with help on this. I'm just learning Java so keep that in mind.

Thanks in advance for reading this or responding!

[344 byte] By [k711a] at [2007-11-27 6:55:48]
# 1
Does the GPS/Yahoo Maps example, http://www.hostj2me.com/appdetails.html?id=2875 , not work for you? It runs fine on my device? If it does not work on your i415 post the issue. It may be something I can quickly resolve.
rashidmayesa at 2007-7-12 18:32:32 > top of Java-index,Java Mobility Forums,Java ME Technologies...
# 2

I didn't try to install on my i415 yet. I am more interested in learning how to use the Wireless Toolkit to build this. I am missing something in accomplishing this. I started a new project called GPS. Put the GPS.java file in APPS/src/ folder. I get three errors when I click build. Something about "package com.astrientlabs.ui does not exist"

"import com.astrientlabs.ui.LocationCanvas();

Plus two other similar errors. (I'd cut and paste it all but WTK wont allow it.

Must need to put all the .java files into folders in the C:\WTK2.5.1\apps\GPS\ ? Need to build each .java file also?

I'm just trying to learn this, so any help is greatly appreciated!

BT

k711a at 2007-7-12 18:32:32 > top of Java-index,Java Mobility Forums,Java ME Technologies...
# 3

Ok, I put all the files in the project in several folders and it compiled without errors. But, when I tried running it on my phone it said MIDP req not met. The GPS.mf file shows need MIDP 2.1 and my phone is MIDP 2.0. So I changed the settings in WTK and compiled again. Still same result. Then I loaded the gps.jad I downloaded and that one works... Why?

Can someone explain/shed some light on this?

Sure wish I could get a simple java midlet that displays the GPS data on the cell screen so I could learn from a WORKING ... SIMPLE example!

Anyone have something like this they could share with a struggling newbie to Java?

ThanksBT

k711a at 2007-7-12 18:32:32 > top of Java-index,Java Mobility Forums,Java ME Technologies...
# 4

Did you create a new package after compiling? After selecting "build" you need to select "create package." After creating the package make certain the jad and jar files reflect the correct platform.

The LocationCanvas has shows how to obtain the coordinates and how to write them to the screen.

Criteria criteria = new Criteria();

locationProvider = LocationProvider.getInstance(criteria);

Location location = locationProvider.getLocation(-1);

coords = location.getQualifiedCoordinates();

I think there may be some confusion around the steps you need to perform to use the src as a WTK project. Source code is different from a Sun WTK ready project. To use the src code in the WTK you must create a project by going to (2.5) "new project". Choose custom settings and make certain to chose 2.0/1.1 and enable the location API.

I am sorry that the aforementioned example was to involved.

Here is a simpler example.

http://www.java-tips.org/java-me-tips/midp/location-based-services-on-j2me-devices-2.html

rashidmayesa at 2007-7-12 18:32:32 > top of Java-index,Java Mobility Forums,Java ME Technologies...
# 5

Thanks for your help and the reference to the easier example!

First of all on the previous one, yes, I did all of the things you indicated. I will try it again later. Maybe I forgot to "make the package" For now I am so happy to figure out the easier one.

I didnt work at first , with 4 errors when I compiled it. I FINALLY compared the file which I copied and pasted into notepad with other files. I noticed that the line :

public class locMidlet extends Midlet implements CommandListener {

(I changed the name to "locMidlet" because when I tried to download to phone it said 16 characters max for filenmaes)

was different than other files I had. The 5th word "Midlet" was different in other files -- IS : "MIDlet" NOT "Midlet"

To my surprise just changing the 2 letters to CAPS fixed all errors, and it runs on my phone! What is that all about? If thats true, why would the example be incorrect?

The Lon & Lat is correct! Only thing is Alt: is "NaN" Not sure what that means.

Thanks again for the help!! I truly appreciate it! This is cool!

BT

PS: Now after I absorb some more, maybe I can figure out how to send data to my webserver... Any links to examples for this?

import javax.microedition.midlet.*;

import javax.microedition.lcdui.*;

import javax.microedition.location.*;

public class locMidlet extends MIDlet implements CommandListener {

Command Exit = new Command("Exit",Command.EXIT,0);

public locMidlet() {}

public void startApp() {

Form f=new Form("Waiting...");

f.append("Finding for location...");

f.addCommand(Exit);

f.setCommandListener(this);

Display.getDisplay(this).setCurrent(f);

try {

Criteria c=new Criteria();

c.setHorizontalAccuracy(1000);

c.setVerticalAccuracy(1000);

c.setPreferredPowerConsumption(Criteria.POWER_USAGE_LOW);

LocationProvider lp=LocationProvider.getInstance(c);

Location loc=lp.getLocation(60);

QualifiedCoordinates qc=loc.getQualifiedCoordinates();

f.append("Alt: "+qc.getAltitude());

f.append("Lat: "+qc.getLatitude());

f.append("Long: "+qc.getLongitude());

} catch(Exception e) {

f.append("Exception: "+e);

}

}

public void pauseApp() {}

public void destroyApp(boolean destroy) {}

public void commandAction(Command c, Displayable s) {

if (c == Exit) {

destroyApp(true);

notifyDestroyed();

}

}

}

k711a at 2007-7-12 18:32:32 > top of Java-index,Java Mobility Forums,Java ME Technologies...