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

  • Home
  • SEARCH
  • 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 9132657
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T08:20:57+00:00 2026-06-17T08:20:57+00:00

I am working on the application in which I need to store the location

  • 0

I am working on the application in which I need to store the location in the database after every 1 minute for that particular device/user.

Suppose if user is moving while the application is open then his coordinates should keep on getting inserted into database after every 1 minute. So for that I have my Web Services setup which can insert the data into the MySql Database. I have tested my WebService in the insertion part, it works fine.

But the problem that I am having is- I don’t think so it is inserting into MySql database for that particular device/user after every 1 minute. Can anyone tell me why it is not happening after every 1 minute? And if there is any problem in the below code, can anyone help me out here by providing some example which will work as per my scenario above?

Any thoughts will be of great help.

private final String id = UUID.randomUUID().toString();
private final String sampleURL = ServerInfo.getServiceURL() + "/insert";

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);    

    locationListener = new GPSLocationListener();

    locationManager.requestLocationUpdates(
            LocationManager.GPS_PROVIDER, 
            60000, 
             0, 
            this.locationListener);

}

Below is the class that implements LocationListener.

private class GPSLocationListener implements LocationListener {
    @Override
    public void onLocationChanged(Location location) {
        if (location != null) {
            GeoPoint point = new GeoPoint(
                    (int) (location.getLatitude() * 1E6), 
                    (int) (location.getLongitude() * 1E6));
                }
     // Below code is used to insert into database
            String userId = id;
            String mLatitude = Double.toString(location.getLatitude());
            String mLongitude = Double.toString(location.getLongitude());
            String mProvider = location.getProvider();
            String mHasAltitude = Boolean.toString(location.hasAltitude());
            String mAltitude = Double.toString(location.getAltitude());
            String mHasSpeed = Boolean.toString(location.hasSpeed());
            String mSpeed = Float.toString(location.getSpeed());
            String mHasBearing = Boolean.toString(location.hasBearing());
            String mBearing = Float.toString(location.getBearing());
            String mHasAccuracy = Boolean.toString(location.hasAccuracy());
            String mAccuracy = Float.toString(location.getAccuracy());

            WebServiceTask wst = new WebServiceTask(WebServiceTask.POST_TASK,
                    getApplicationContext(), "Posting data...");

            wst.addNameValuePair("user_id", userId);
            wst.addNameValuePair("mlatitude", mLatitude);
            wst.addNameValuePair("mlogitude", mLongitude);
            wst.addNameValuePair("mprovider", mProvider);
            wst.addNameValuePair("mhasAltitude", mHasAltitude);
            wst.addNameValuePair("mAltitude", mAltitude);
            wst.addNameValuePair("mhasspeed", mHasSpeed);
            wst.addNameValuePair("mspeed", mSpeed);
            wst.addNameValuePair("mhasbearing", mHasBearing);
            wst.addNameValuePair("mbearing", mBearing);
            wst.addNameValuePair("mhasaccuracy", mHasAccuracy);
            wst.addNameValuePair("maccuracy", mAccuracy);

            // This will insert into database
            wst.execute(new String[] { sampleURL });


    }

    @Override
    public void onProviderDisabled(String provider) {
    }

    @Override
    public void onProviderEnabled(String provider) {
    }

    @Override
    public void onStatusChanged(String provider, int status, Bundle extras) {
    }
}

NOTE:- It is inserting into Database but it’s not inserting at exactly or approximately in the time interval I need which is of 1 minute

  • 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-06-17T08:20:58+00:00Added an answer on June 17, 2026 at 8:20 am

    This problem may be caused by several issues which are not directly under your control as a programmer. Some that come to mind are

    1. The network may not be available and therefore no positioning data can be sent to your app.

    2. An ill-behaved app is taking up CPU time and the OS doesn’t interrupt it within your desired time interval.

    In general, getting exact timing on a device designed for multi-tasking is nearly impossible. There can also be issues with getting data at “approximate” time intervals depending on what margin of error you can accept.

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

Sidebar

Related Questions

I am working on an application in which i need to store all the
I am working on an Application which would need to store small files (images
Hi i am working on an application in which i need to upload a
I am currently working on an application in-which I need to take the screenshot
Hi I am working on an application in which I need almost 10 webBrowsers
I am working on a blackberry application in which I need to hit a
I'm working on an android tablet application using phonegap in which i need to
I'm working on an application which allows employees to Request time off that post
I am working on a Java desktop application in which I need to implement
I'm working on an application which should import all e-mails from a user's e-mail-account

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.