Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7061963
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T04:32:14+00:00 2026-05-28T04:32:14+00:00

I am trying to implement jsr-179 APi into Nokia Symbian phone for periodic location

  • 0

I am trying to implement jsr-179 APi into Nokia Symbian phone for periodic location update using setLocationListener through J2me. In emulator it is working fine. While I installed Midlet on the device nokia 5230, it is given NullPointerException and the application is automatically terminating. What might be possible causes?

Below is my class, I am instantiating object for this class on a form in netbeans

class MovementTracker implements LocationListener {

        LocationProvider provider;
        Location lastValidLocation;
        UpdateHandler handler;
        boolean done;

    public MovementTracker() throws LocationException
    {

    done = false;
    handler = new UpdateHandler();
    new Thread(handler).start();

        //Defining Criteria for Location Provider
       /*
        Criteria cr = new Criteria();
        cr.setHorizontalAccuracy(500);
       */


        //you can place cr inside getInstance
    provider = LocationProvider.getInstance(null);

        //listener,interval,timeout,int maxAge
        //Passing -1 selects default interval
       // provider.setLocationListener(MovementTracker.this, -1, -1, -1);
         provider.setLocationListener(MovementTracker.this, -1, 30000, 30000);

    }

    public void locationUpdated(LocationProvider provider, Location location)
    {
    handler.handleUpdate(location);
        batteryLevel = System.getProperty("com.nokia.mid.batterylevel");
        sn = System.getProperty("com.nokia.mid.networksignal");
        localTime =  System.currentTimeMillis();

        Send_Location();
    }

    public void providerStateChanged(LocationProvider provider, int newState)
    {
    }

    class UpdateHandler implements Runnable
    {
    private Location updatedLocation = null;

    // The run method performs the actual processing of the location

    public void run()
        {
        Location locationToBeHandled = null;
        while (!done)
            {
        synchronized(this)
                {
            if (updatedLocation == null)
                    {
            try
                        {
                wait();
            }
                        catch (Exception e)
                        {
                // Handle interruption
            }
            }
            locationToBeHandled = updatedLocation;
            updatedLocation = null;
        }

        // The benefit of the MessageListener is here.
        // This thread could via similar triggers be
        // handling other kind of events as well in
        // addition to just receiving the location updates.
        if (locationToBeHandled != null)
            processUpdate(locationToBeHandled);
        }
                try
                {
                    Thread.sleep(10000); //Sleeps for 10 sec & then sends the data
                }
                catch (InterruptedException ex)
                {
                }


    }

    public synchronized void handleUpdate(Location update)
        {
        updatedLocation = update;
        notify();
    }

    private void processUpdate(Location update)
        {
        latitude = update.getQualifiedCoordinates().getLatitude();
            longitude = update.getQualifiedCoordinates().getLongitude();
            altitude = update.getQualifiedCoordinates().getAltitude();

    }
    }
} 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T04:32:15+00:00Added an answer on May 28, 2026 at 4:32 am
    public MovementTracker() throws LocationException
    

    …
    I have not written any code for handling LocationException.

    No code is very dangerous practice, just search the web for something like “java swallow exceptions”.

    It is quite possible that because of implementation specifics Nokia throws LocationException where emulator does not throw it. Since you don’t handle exception this may indeed crash you midlet at Nokia – and you wouldn’t know the reason for that because, again, you have written no code to handle it.

    How can I catch that exception?

    The simplest thing you can do is to display an Alert with exception message and exit the midlet after user reads and dismisses alert

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying implement a SQL INSERT command into my MS Access database using
I am trying implement Using local storage with BLOB storage . I went through
Trying to implement Piwik using REST API over http but need a little help.
I am trying implement a most recent widget into my tumblr post. So far,
I'm trying implement a way to recursively template using jsRender. The issue is, my
I'm trying implement a bracket in my program (using C#/.NET MVC) and I am
trying to implement a multiplayer. Using the sample from Game Center - Sending and
Trying to implement the new FP 10.1 Global error handler into my projects but
Just trying to implement mobFox into my app, but having trouble to make it
Im trying to implement a UnitofWork pattern using this Scott Allen tutorial My current

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.