×

Discussion Board

Page 1 of 3 123 LastLast
Results 1 to 15 of 32
  1. #1
    Regular Contributor
    Join Date
    Jan 2008
    Posts
    272

    Thumbs up How to work on Location API

    Hello friends,

    1. I want to get the present location of the device.

    For example if I am in Hyderabad, I want to get the location of the device as Hyderabad.

    How to do it? I go through the LocationAPI. I dont know how to use this API?

    2.What is the meaning of Criteria?

    3.How can I use Location API?

    4.How to include maps and integrate the code to use maps?

    Please help me.

    Thanks,
    Manoj.

  2. #2
    Nokia Developer Moderator
    Join Date
    Oct 2007
    Location
    Deva, Romania
    Posts
    3,471

    Re: How to work on Location API

    Hi Manoj,

    Quote Originally Posted by manojkumar.m View Post
    2.What is the meaning of Criteria?
    Criteria takes parameters to help determine the most appropriate location provider, which is the one that best matches the defined criteria.

    Quote Originally Posted by manojkumar.m View Post
    3.How can I use Location API?
    See this collection of articles, in addition to the Location API documentation.

    Quote Originally Posted by manojkumar.m View Post
    4.How to include maps and integrate the code to use maps?
    J2ME Google Maps API
    How to use Google Maps data in mobile applications

  3. #3
    Regular Contributor
    Join Date
    Jan 2008
    Posts
    272

    Re: How to work on Location API

    Hi friends,

    I have written a small example which gets the latitude and longitude of the mobile device.

    Its working fine on s60 emulator (eclipse 3.1 + carbide j1.5, S60 3rd edition fp1).

    But when I tried to run the same example on E61I, Nothing is happened.

    Here is my code:
    import javax.microedition.lcdui.*;
    import javax.microedition.midlet.*;

    public class MidletLocation extends MIDlet implements CommandListener
    {
    Display display;
    Form form;
    Command showLocation;
    Command exit;

    public MidletLocation()
    {


    }
    protected void startApp( ) throws MIDletStateChangeException
    {
    display = Display.getDisplay(this);
    form = new Form("Location Form");
    showLocation = new Command("ShowLocation",Command.SCREEN,1);
    exit = new Command("Exit",Command.EXIT,0);
    form.addCommand(showLocation);
    form.addCommand(exit);
    form.setCommandListener(this);
    if(form != null)
    {
    System.out.println("form is not null.");
    display.setCurrent(form);
    }
    else
    {
    System.out.println("form is null.");
    }
    }

    protected void destroyApp( boolean p1 ) throws MIDletStateChangeException
    {
    }

    protected void pauseApp( )
    {
    }

    public void commandAction( Command c, Displayable p2 )
    {
    if(c == showLocation)
    {

    try
    {
    LocationImplementation li = new LocationImplementation(this);
    }
    catch(Exception e)
    {
    System.out.println("Exception caught:"+e);
    }
    }
    else
    if(c == exit)
    {
    this.notifyDestroyed();
    }
    }

    public void setLocation(String msg)
    {
    form.append(msg);
    }

    public void showForm()
    {
    display.setCurrent(form);
    }
    }


    import javax.microedition.location.*;

    public class LocationImplementation implements LocationListener
    {
    MidletLocation m_midlet;
    LocationProvider provider;
    Location lastValidLocation;
    UpdateHandler handler;
    boolean done;
    public LocationImplementation(MidletLocation arg_midlet) throws LocationException
    {
    m_midlet = arg_midlet;
    done = false;
    handler = new UpdateHandler();
    provider = LocationProvider.getInstance(null);
    provider.setLocationListener(this, -1, -1, -1);
    new Thread(handler).start();

    }
    public LocationImplementation()
    {
    }
    public void locationUpdated( LocationProvider p1, Location location )
    {
    //handler.handleUpdate(location);
    }

    public void providerStateChanged( LocationProvider p1, int p2 )
    {
    }

    class UpdateHandler implements Runnable
    {
    private Location updatedLocation = null;
    Coordinates c;
    String msg;

    // The run method performs the actual processing of the location
    // updates
    public void run()
    {
    try
    {
    updatedLocation = provider.getLocation(60);
    c = updatedLocation.getQualifiedCoordinates();
    if(c != null )
    {
    // Use coordinate information
    double lat = c.getLatitude();
    double lon = c.getLongitude();
    msg = "\nLatitude : " + lat + "\nLongitude : " + lon;
    }
    else
    {
    msg ="Location API failed";
    }
    System.out.println("setting the locations information to form.");
    m_midlet.setLocation(msg);
    m_midlet.showForm();
    }
    catch(Exception e)
    {
    System.out.println("Exception at handler:"+e);
    }

    }
    }
    }

    Do I need to do any settings for this? I have given permissions:
    javax.microedition.location.Location.
    And signed the application also.

    Could you please help me?

    Thanks,
    Manoj.

  4. #4
    Registered User
    Join Date
    Oct 2007
    Posts
    48

    Re: How to work on Location API

    do you have got an GPS connected? the e61i doesnt has it build-in.

  5. #5
    Regular Contributor
    Join Date
    Jan 2008
    Posts
    272

    Re: How to work on Location API

    Quote Originally Posted by njk View Post
    do you have got an GPS connected? the e61i doesnt has it build-in.
    How to test whether my E61I has built-in GPS connected?

  6. #6
    Regular Contributor
    Join Date
    Jan 2008
    Posts
    272

    Re: How to work on Location API

    My E61I has Bluetooth GPS. Is it not sufficient?

  7. #7
    Registered User
    Join Date
    Oct 2007
    Posts
    48

    Re: How to work on Location API

    i mean: the Nokia E61i does not have a build-in gps device, so you have to connect a bluetooth gps for example. If you got no external gps your application will not work on your e61i.

    sorry ok. i read it

  8. #8
    Regular Contributor
    Join Date
    Jan 2008
    Posts
    272

    Re: How to work on Location API

    Quote Originally Posted by njk View Post
    i mean: the Nokia E61i does not have a build-in gps device, so you have to connect a bluetooth gps for example. If you got no external gps your application will not work on your e61i.
    How to connect bluetooth GPS? and how to got external GPS?

  9. #9
    Registered User
    Join Date
    Oct 2007
    Posts
    48

    Re: How to work on Location API

    normally if you start your application, a bluetooth search starts. does that happen?

  10. #10
    Regular Contributor
    Join Date
    Jan 2008
    Posts
    272

    Re: How to work on Location API

    No that is not happening.

  11. #11
    Registered User
    Join Date
    Oct 2007
    Posts
    48

    Re: How to work on Location API

    if your starting your application your questioned something like "would you like to ... location". thats automatically asked by symbian. with this question your asked "would you like to use bluetooth".

  12. #12
    Registered User
    Join Date
    Oct 2007
    Posts
    48

    Re: How to work on Location API

    in your code i dont find any criteria.. try to make an aplication based one the artikels in:
    http://wiki.forum.nokia.com/index.ph...ation_Articles

    its an stepbystep tutorial. and your are quite far.

  13. #13
    Regular Contributor
    Join Date
    Jan 2008
    Posts
    272

    Re: How to work on Location API

    Quote Originally Posted by njk View Post
    if your starting your application your questioned something like "would you like to ... location". thats automatically asked by symbian. with this question your asked "would you like to use bluetooth".
    No it is not asking any questions like you mentioned.

    My device also paired with another bluetooth enabled device.

    What should I do?

    Thanks,
    Manoj.

  14. #14
    Registered User
    Join Date
    Oct 2007
    Posts
    48

    Re: How to work on Location API

    "In devices where JSR 179 - Location API is implemented, there's no need to directly use JSR 82 (Bluetooth API) to read location data, since the Location API does all the necessary work for retrieval of the location data itself:

    * Searching the GPS module in the BT local area
    * Pairing with GPS device
    * Retrieval of positioning data
    * Parsing of low-level NMEA sentences, turning them into high-level Java objects. "

    if youve implemented the location thing correctly everything will be done by the device itself. you dont even have to pair it bevor starting the application.

  15. #15
    Regular Contributor
    Join Date
    Jan 2008
    Posts
    272

    Re: How to work on Location API

    Quote Originally Posted by njk View Post
    "In devices where JSR 179 - Location API is implemented, there's no need to directly use JSR 82 (Bluetooth API) to read location data, since the Location API does all the necessary work for retrieval of the location data itself:

    * Searching the GPS module in the BT local area
    * Pairing with GPS device
    * Retrieval of positioning data
    * Parsing of low-level NMEA sentences, turning them into high-level Java objects. "

    if youve implemented the location thing correctly everything will be done by the device itself. you dont even have to pair it bevor starting the application.
    Now I changed the code:
    cr.setHorizontalAccuracy(500);
    provider = LocationProvider.getInstance(cr);

    Now, when I installed the applicaiton on E61I, when I run the applicaiton, a bluetooth symbol blinked for a while and nothing happened.

    Can you try my example at your desk and install on any device?


    Thanks,
    Manoj.

Similar Threads

  1. S60 API Partnering Program
    By Nokia Ron in forum News and Announcements
    Replies: 9
    Last Post: 2008-04-16, 18:28
  2. Location API security limitations?
    By jkirma in forum Mobile Java Networking & Messaging & Security
    Replies: 2
    Last Post: 2006-05-29, 06:10
  3. Location API panics
    By Kimple in forum Symbian
    Replies: 1
    Last Post: 2005-12-21, 14:21
  4. How to get Nokia UI API to work?
    By eyvind1 in forum Mobile Java Tools & SDKs
    Replies: 4
    Last Post: 2004-09-22, 13:51
  5. Location API (JSR 179) in Nokia Phones
    By mgruebsch in forum Mobile Java General
    Replies: 1
    Last Post: 2004-09-17, 04:50

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •