×

Discussion Board

Results 1 to 7 of 7
  1. #1
    Registered User
    Join Date
    Jan 2013
    Posts
    21

    help on accessing inbuilt gps of mobile device

    how do i access inbuilt gps of mobile device or emulator in java, for my project i want to get my current location automatically as i have the code for it
    String string;
    LocationProvider lp ;
    Coordinates c;
    // Set criteria for selecting a location provider:
    // accurate to 500 meters horizontally
    Criteria cr= new Criteria();
    public void startApp()
    {
    try {
    ApplicationContext.getInstance().setToken("rNfKF7rkL6ERcji5fXFDWg");
    ApplicationContext.getInstance().setAppID("xMFc0ozI03u-KzEQ--MG");
    cr.setHorizontalAccuracy(1000);
    cr.setVerticalAccuracy(1000);
    cr.setPreferredPowerConsumption(Criteria.POWER_USAGE_HIGH);
    LocationProvider lp= LocationProvider.getInstance(cr);
    Location loc = lp.getLocation(-1);
    QualifiedCoordinates qc =loc.getQualifiedCoordinates();
    Display display = Display.getDisplay(this);
    MapDemo minimalMap = new MapDemo(display, this);
    minimalMap.getMapDisplay().setCenter(new GeoCoordinate(qc.getLatitude(),qc.getLongitude(),qc.getAltitude()));
    minimalMap.getMapDisplay().setZoomLevel(14,0,0);
    display.setCurrent(minimalMap);

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

    protected void pauseApp()
    {
    throw new UnsupportedOperationException("Not supported yet.");
    }

    protected void destroyApp(boolean unconditional) throws MIDletStateChangeException {
    throw new UnsupportedOperationException("Not supported yet.");
    }

    }
    class MapDemo extends Base {
    public MapDemo(Display display, MIDlet midlet) {
    super(display, midlet);
    }
    }

    class Base extends MapCanvas implements CommandListener {

    private final Command EXIT = new Command("Exit", Command.EXIT, 1);
    protected MIDlet midlet; // for notifyDestroyed

    public Base(Display display, MIDlet midlet) {
    super(display);
    this.midlet = midlet;
    addCommand(EXIT);
    setCommandListener(this);
    }

    public void commandAction(final Command c, Displayable d) {
    Command YES = new Command("YES", Command.OK, 1);
    Command NO = new Command("NO", Command.OK, 1);
    if (c == EXIT)
    {
    midlet.notifyDestroyed();
    }
    else if (c == YES)
    {
    map.reconnect();
    display.setCurrent(this);
    }
    else if (c == NO)
    {
    display.setCurrent(this);
    }
    else
    {

    commandRun(c);

    }
    }

    private void commandRun(Command c) {

    }

    public void onMapUpdateError(String string, Throwable thrwbl, boolean bln)
    {

    }

    public void onMapContentComplete()
    {
    throw new UnsupportedOperationException("Not supported yet.");
    }
    }


    this code is not displaying my current location, and it is Showing me dynamic coordinates every time i run .... but if i give coordinates of particular location manually in GeoCoordinate method it is showing me the exact location but the thing is i want it to read automatically my current location...and display it on my map
    can anyone plzz help me about where i am going wrong or first should i need some code to first connect to inbuilt gps of mobile device
    IF YES THEN
    what is the idea behind connecting inbuilt GPS of mobile device or emulator
    IF NO
    how i will get my current location coordinates
    plzz help

    thankss
    swati

  2. #2
    Super Contributor
    Join Date
    Apr 2007
    Posts
    2,708

    Re: help on accessing inbuilt gps of mobile device

    ok just to make it absolutely clear : NO, you wont be able to get your actual location through the emulator... Keep in mind it's an emulator, GPS is a combination of hardware and software, and what you are missing is actually the hardware (GPS chipset and for example an inbuilt antenna to receive the GPS signals)....
    So what the emulator can do for you is actually "simulate" or "spoof" a location, which is supplied by you or might be generated randomly, so this position is NOT your actual position !!!
    You will need real actual hardware (a device with inbuilt gps or an external gps-mouse) to actually read out your actual position...
    To me it sounds you might want to learn a little more about a software emulator in general (again an emulator is not an actual device, for example you cannot use the camera just as you cannot use the internal GPS) and how GPS (chipsets) work....

    Also you might want to have a look at this discussion :
    http://www.developer.nokia.com/Commu...e-in-build-GPS
    Note: please don't send private questions to me, as I don't have time to provide private support. All such questions should be posted on public forums, where I and others can see and answer them.

  3. #3
    Registered User
    Join Date
    Jan 2013
    Posts
    21

    Re: help on accessing inbuilt gps of mobile device

    so every time i want to test my app have to install that app in mobile having inbuilt gps ... i have Nokia E52 which has inbuilt GPS but in that it is only asking for my bluetooth connection and awaiting for the signal and finally cannot find any signal .... is there any mistakes or some missing part in my code so that i can cross check whether my code is right or wrong .. i am stuck here since a month plzz help..


    thankss
    swati

  4. #4
    Nokia Developer Champion
    Join Date
    Feb 2009
    Location
    Noida, India
    Posts
    3,087

    Re: help on accessing inbuilt gps of mobile device

    Quote Originally Posted by swatik View Post
    so every time i want to test my app have to install that app in mobile having inbuilt gps ... i have Nokia E52 which has inbuilt GPS but in that it is only asking for my bluetooth connection and awaiting for the signal and finally cannot find any signal .... is there any mistakes or some missing part in my code so that i can cross check whether my code is right or wrong .. i am stuck here since a month plzz help..


    thankss
    swati
    Check the device settings is the inbuilt GPS/ A-GPS is off or disabled - On/enable it before testing this app.

    Also test running apps like Google Maps or Nokia Maps or any default device location app and test in open sky to see if your gets a GPS lock first... if it works then test your J2me app it should also get the GPS location.
    thanks,
    ~Amitabh
    (Champion of the Month -Aug'13)
    Follow me on my blog for Innovative Mobile Apps

  5. #5
    Super Contributor
    Join Date
    Apr 2007
    Posts
    2,708

    Re: help on accessing inbuilt gps of mobile device

    Have a look at :
    http://www.developer.nokia.com/Commu..._using_Java_ME

    Also there are other handy articles on the Wiki regarding Location and JSR 179
    Note: please don't send private questions to me, as I don't have time to provide private support. All such questions should be posted on public forums, where I and others can see and answer them.

  6. #6
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,765

    Re: help on accessing inbuilt gps of mobile device

    Quote Originally Posted by swatik View Post
    so every time i want to test my app have to install that app in mobile having inbuilt gps ...
    i am stuck here since a month plzz help..
    Why would you need the emulator to provide your real coordinates (which it can not do anyway)? It is a good thing actually that you can set the emulator to think itself being anywhere on the planet.

  7. #7
    Super Contributor
    Join Date
    Nov 2003
    Location
    Bangalore , India
    Posts
    4,429

    Re: help on accessing inbuilt gps of mobile device

    Just to add : I hope you have seen Route Editor in Nokia SDK 2.0 for Java / Series 40 SDK's - Would Route Editor help in your case ?

    Regards
    Gopal

Similar Threads

  1. can not build inbuilt Qt Quick Demos with Symbian device Build on new Qt SDK1.1 TP
    By chintandave_er in forum [Archived] Qt SDKs and Tools
    Replies: 12
    Last Post: 2011-02-08, 20:43
  2. n97 inbuilt applicatin accessing internet (GPRS) in background
    By honest_success in forum Series 40 & S60 Platform Feedback Archive
    Replies: 2
    Last Post: 2009-10-10, 15:52
  3. Replies: 5
    Last Post: 2009-01-07, 09:36
  4. Mobile Networking: Accessing Mobile from server on internet
    By go4jas in forum Mobile Java Networking & Messaging & Security
    Replies: 1
    Last Post: 2006-11-08, 13:23
  5. Accessing device info
    By dgiel in forum Mobile Java General
    Replies: 3
    Last Post: 2002-05-22, 12:58

Posting Permissions

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