JSR-179 Location API on not supported phones
Hi,
I'm creating a navigation midlet. It gets positions thru bluetooth and an external GPS receiver. Now i want to implement JSR-179 Location API to use the built in GPS unit of some new phones. This means if the phone supports JSR-179 then the build in GPS should be used, if not BT discovery will start.
Is it possible to do this in one single midlet? I've made some quick tests and my midlet didn't start at all on non JSR-179 phones, saying "No Class Def Found Error" and references some JSR-179 classes. Is it possible to check at runtime if the API is supported and avoid this error somehow? Or do I have to create two different midlets for the two different type of phones?
Thanks a lot!
Ors
Re: JSR-179 Location API on not supported phones
if (System.getProperty("microedition.location.version") == null)
{
/* Location Package is NOT installed */
return false;
}
else
{
/* Location Package is installed */
return true;
}
Try that ;)
Re: JSR-179 Location API on not supported phones
you need separated classes that won't be loaded if the jsr179 is not present.
it means that there is a test like tiger wrote, and everything that refers to the 179 must be conditionned by this, even imports.
Re: JSR-179 Location API on not supported phones
Both of you are right.
1) Do not import JSR 179 classes on the main midlet.
2) Test whether JSR 179 is implemented on the midlet constructor.
3) Make sure any classes using JSR 179 on non-enabled phones do not get loaded (a.k.a. do not create instances of them)
and you should be fine.
Daniel
Re: JSR-179 Location API on not supported phones
Hi All,
Thanks for your suggestions, I understand the recommended approach, however not sure about the implementation:
1. In other classes then the main midlet, can i import those classes? If NOT: how can i avoid this? The code below seems to be illegal:
...
import java.util.TimerTask;
import Real.*;
if (System.getProperty("microedition.location.version") != null)
{
import javax.microedition.location.Location;
import javax.microedition.location.LocationException;
}
2. In other classes then the main midlet, can a create objects of that class? If NOT: how can i avoid it? The code below is illegal:
public class GPSReader extends TimerTask
{
int counter = 0;
if (System.getProperty("microedition.location.version") != null)
{
Location loc;
}
Thanks a lot!
Örs
Re: JSR-179 Location API on not supported phones
Wooow, what a nice solution!
Thanks Traud!
Örs
Re: JSR-179 Location API on not supported phones
I want to know the "nice solution", 'cause I have the same problem. In the link traud introduce, it's only the JSR 248.
Re: JSR-179 Location API on not supported phones
[i][url=http://wiki.forum.nokia.com/index.php/How_to_use_an_optional_API_in_Java_ME]How to use an optional API in Java ME[/url][/i].
I hope this helps.
Cheers,
Graham.
Re: JSR-179 Location API on not supported phones
i am using nokia c2-00. according to given manual , it supports jsr-179. but when i try to load a location package class in my program, it is throwing an exception....cant load Location class...
why is it showing this error?
Re: JSR-179 Location API on not supported phones
In nokia c2-00, can i use javax.microedition.location package to develop an app ?
Re: JSR-179 Location API on not supported phones
[QUOTE=ramakrishnanokia;908970]In nokia c2-00, can i use javax.microedition.location package to develop an app ?[/QUOTE]
Nokia C2-00 do not support JSR 179 -- its Series 40 5th Ed. FP1 Lite SDK based deice --- Please check the specs at [url]https://www.developer.nokia.com/Devices/Device_specifications/C2-00/[/url]
Re: JSR-179 Location API on not supported phones
Thank u....
Nokia 110 is also Series 40 5th Ed. FP1 Lite SDK... At the same time it has Nokia SDK 1.1 for Java also..
Is it going to useful to use Location Api?
Re: JSR-179 Location API on not supported phones
Yes, Nokia 110 supports JSR 179 and you can use it.
You check which location providers are present on the device and use it.
If the device does not have in-built GPS chip, JSR 179 will try to search for Bluetooth based GPS receiver from which it can fetch the location co-ordinates.
Re: JSR-179 Location API on not supported phones
Thank u...
Is it possible to get jar for com.nokia.mid.location package?
API bridge is applicable for Nokia Series 60 ... is there any other technique available in series 40 to get device location information ?