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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T17:52:17+00:00 2026-06-13T17:52:17+00:00

I am trying to send GPS coordinates to server in every 1 minute interval

  • 0

I am trying to send GPS coordinates to server in every 1 minute interval through a background service . It invokes the service for thee first time but it doesn’t repeat it .

Code for setting the alarm:

Intent gpsIntent = new Intent(CheckInActivity.this, GoogleMapService.class);
                    gpsPendingIntent = PendingIntent.getService(CheckInActivity.this, 0, gpsIntent, 0);
                    AlarmManager alarmManager_gps = (AlarmManager)getSystemService(ALARM_SERVICE);

                    Calendar calendar_gps = Calendar.getInstance();
                    calendar_gps.add(Calendar.SECOND, 20);
                    alarmManager_gps.setRepeating(AlarmManager.RTC_WAKEUP, calendar_gps.getTimeInMillis(), TimeUnit.MINUTES.toMillis(1), gpsPendingIntent);

Service

    public class GoogleMapService extends Service {

private boolean gps_enabled = false;
private boolean network_enabled = false;
private static Location sLocation;   
private LocationManager locManager;
private LocationListener locListener = new MyLocationListener();
private CallBack callback;

@Override
public void onCreate() {

}

@Override
public IBinder onBind(Intent intent) {

    Log.w(null,"GPS Service called");
    locManager = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE);
    try {
        gps_enabled = locManager.isProviderEnabled(LocationManager.GPS_PROVIDER);
    } catch (Exception ex) {
    }
    try {
        network_enabled = locManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER);
    } catch (Exception ex) {
    }

    if (gps_enabled) {
        locManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, locListener);
    }
    if (network_enabled) {
        locManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, locListener);
    }

    callback = new CallBack() {

        public void onResult(Boolean result) {
            // TODO Auto-generated method stub

        }

        public void onProgress() {
            // TODO Auto-generated method stub

        }
    };

    return null;
}

@Override
public void onDestroy() {
    super.onDestroy();
}

@Override
public void onStart(Intent intent, int startId) {       
    super.onStart(intent, startId);
}

@Override
public boolean onUnbind(Intent intent) {
    return super.onUnbind(intent);
}

class MyLocationListener implements LocationListener {

    public void onLocationChanged(Location location) {
        if (location != null) {
            // This needs to stop getting the location data and save the battery power.
            locManager.removeUpdates(locListener);
            sLocation = location;
            Model.coordinates = location.getLatitude() + "," + location.getLongitude();
            try{
                SendGPSCoordinatesOperation task = new SendGPSCoordinatesOperation(callback);
                task.execute("");
                Log.w(null,"Sent");
            }
            catch(Exception e){
                Log.w(null,"Couldn't be sent");
            }
            Log.w(null,"The coordinates are"+Model.coordinates);
        }
    }

    public void onProviderDisabled(String provider) {
        // TODO Auto-generated method stub

    }

    public void onProviderEnabled(String provider) {
        // TODO Auto-generated method stub

    }

    public void onStatusChanged(String provider, int status, Bundle extras) {
        // TODO Auto-generated method stub

    }
}

}

EDIT : AndroidManifest code

  • 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-13T17:52:18+00:00Added an answer on June 13, 2026 at 5:52 pm

    Use this…

    private void setLocationSendingAlarm() {
    
            AlarmManager alarmManager = (AlarmManager) getApplicationContext().getSystemService(Context.ALARM_SERVICE);
            Intent intent = new Intent(getApplicationContext(), GoogleMapService.class);
            intent.putExtra("locationSendingAlarm", true);
            PendingIntent   pendingIntent = PendingIntent.getService(this, 987654321, intent,0);
            try {
                alarmManager.cancel(pendingIntent);
            } catch (Exception e) {
    
            }
            int timeForAlarm=60000;
    
    
            alarmManager.setRepeating(AlarmManager.RTC_WAKEUP,System.currentTimeMillis()+timeForAlarm, timeForAlarm,pendingIntent);
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to implement a thread so that I can send GPS coordinates in
I´m trying to send a image through tcp to a server, firts getting the
I'm trying to take two doubles (GPS coordinates) and send them over the ZigBee
I am trying to write a program that will send GPS coordinates using telnet.
I'm trying send flash messages and welcome notices to users if it's their first
trying to send several mails with specific attachments for each address. every address has
I am trying to send a simple email through the following code: protected void
im trying to send a unix command from a client to a server, wait
I'm trying to store a user ID (key) and an array of GPS coordinates
I'm trying to have GPS coordinates sent to a text message. This code works,

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.