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 7535337
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T06:16:51+00:00 2026-05-30T06:16:51+00:00

I have to send my current location details (lat & long) to server periodically

  • 0

I have to send my current location details (lat & long) to server periodically (Ex: for every 5 minutes). Is there any best way? I know how to get the current location & how to send the details to server. But how do I repeat this in periodic intervals?

  • 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-30T06:16:52+00:00Added an answer on May 30, 2026 at 6:16 am

    Register an alarm using AlarmManager to wake up after 5min when user open the application first time. create a service(fetch location and update to server) to run when alarm notifies your application. After the service finished the work , register for an alarm again to wake up after 5min. by this way you can achieve your task.

    ref

    Android: How to periodically send location to a server

    http://developer.android.com/reference/android/app/AlarmManager.html

    http://developer.android.com/reference/android/app/Service.html

    1st Edit – Adding code sample

    Step 1 – Create alarm manager and register alarm

    AlarmManager alarmMgr = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
    
    Intent intent = new Intent(Main.this, YourWakefulReceiver.class);
    bool flag = (PendingIntent.getBroadcast(Main.this, 0,
                    intent, PendingIntent.FLAG_NO_CREATE)==null);
    /*Register alarm if not registered already*/
    if(flag){
    PendingIntent alarmIntent = PendingIntent.getBroadcast(Main.this, 0,
                        intent, PendingIntent.FLAG_UPDATE_CURRENT);
    
    // Create Calendar obj called calendar
            Calendar calendar = Calendar.getInstance();
    
    /* Setting alarm for every one hour from the current time.*/
    int intervalTimeMillis = 1000 * 60 * 60; // 1 hour 
    alarmMgr.setRepeating(AlarmManager.RTC_WAKEUP,
                            calendar.getTimeInMillis(), intervalTimeMillis,
                            alarmIntent);
    }
    

    Step 2 – Create Receiver class

    public class YourWakefulReceiver extends WakefulBroadcastReceiver {
    
        @Override
        public void onReceive(Context context, Intent intent) {
                Intent service = new Intent(context, SimpleWakefulService.class);
                startWakefulService(context, service);
            }
        }
    }
    

    Setp 3 – Create Service class

    public class SimpleWakefulService extends IntentService {
    
        private static String tagName = "YourService";
    
        public SimpleWakefulService() {
            super("YourService");
        }
    
        @Override
        protected void onHandleIntent(Intent intent) {
            // Start your location
            LocationUtil.startLocationListener();
            try {
            // Wait for 10 seconds
                Thread.sleep(1000*10);
            } catch (InterruptedException e) {
            }
            //Stop location listener
            LocationUtil.stopLocationListener();
            // upload or save location
            uploadGps();
    
            SimpleWakefulReceiver.completeWakefulIntent(intent);
        }
    
    }
    

    Step 4 – Register service and receiver

    <service android:name="com.envision.ghari.services.SimpleWakefulService"></service>
            <receiver android:name="com.envision.ghari.receivers.YourWakefulReceiver"></receiver>
    

    Note : This code is to understand the implementation. It will not compile.

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

Sidebar

Related Questions

For my current project I have to send a signature from PHP to Java
I have to send .csv file to remote server through REST in rails. I
I have to send a long string of data through webservice to database.I odnt
I want to send my current location latitude,longitude to my friend via sms. This
I have an application in which there is Google map, location overlays on Google
In my application I have get directions from the user's current location. When a
Suppose I have this script : http://www.example.com/profile.php?uid=12345 And inside this script, there's a send
I have a this function to grab the lat and long in my app
Here is what I have currently, I'm doing this: current_account.send(object).search(params[:search]).user_id_equals_any(users).visibility_is_any(visibilities) but thats not very
I have send an email using php mailer class. mail was sending successfully but

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.