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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T17:02:07+00:00 2026-06-02T17:02:07+00:00

I have GPS Tracking application main goal is saving GPS coordinate to backed database

  • 0

I have GPS Tracking application main goal is saving GPS coordinate to backed database every 5 minutes interval. So i created Service & receiver because even my my application doesn’t open / run this should work.

After user enter executive code , it create database and go to welcome screen.
In there it start GPS capturing & save it to PDA database calling service to upload. I have receiver, when phone isBooted it start this receiver & receiver call service.

My problem is receiver doesn’t call service. It didn’t go to Service class.

  protected void onStop(){
    super.onStop();
    if(gpsReceiver != null){
        unregisterReceiver(gpsReceiver);
    }
}

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

    gpsReceiver = new GpsReceiver();
    IntentFilter intentFilter1 = new IntentFilter(Intent.ACTION_BOOT_COMPLETED);
    intentFilter1.addAction(Intent.ACTION_BOOT_COMPLETED);
    intentFilter1.addAction(Intent.ACTION_POWER_CONNECTED);
    intentFilter1.addAction(Intent.ACTION_SCREEN_ON);
    registerReceiver(gpsReceiver, intentFilter1);

    locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
    locationManager.requestLocationUpdates(
           LocationManager.GPS_PROVIDER, 
           MINIMUM_TIME_BETWEEN_UPDATES, 
           MINIMUM_DISTANCE_CHANGE_FOR_UPDATES,
           new MyLocationListener()
    );
    locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, new MyLocationListener());
 }

 private class MyLocationListener implements LocationListener {
        public void onLocationChanged(Location location) {
            String message = String.format( "Location \n Longitude: %1$s \n Latitude: %2$s", location.getLongitude(), location.getLatitude());
            longitude = location.getLongitude();
            latitude =location.getLatitude();

            //save GPS coordinate to PDA DB
            GPSDBAdapter dbAdapter = GPSDBAdapter.getDBAdapterInstance(HomeActivity.this);
            dbAdapter.openDataBase();
            dbAdapter.insertGPS(longitude, latitude, "MASS", deserializeObject());
            dbAdapter.close(); 

            //After save GPS coordinate it upload to backend using service
            startService(new Intent(HomeActivity.this, UploadService.class));
            Toast.makeText(HomeActivity.this, message, Toast.LENGTH_LONG).show();
        }

        public void onStatusChanged(String s, int i, Bundle b) {
            Toast.makeText(HomeActivity.this, "Provider status changed",Toast.LENGTH_LONG).show();
        }

        public void onProviderDisabled(String s) {
           Toast.makeText(HomeActivity.this,"Provider disabled by the user. GPS turned off",Toast.LENGTH_LONG).show();
        }
        public void onProviderEnabled(String s) {
          Toast.makeText(HomeActivity.this, "Provider enabled by the user. GPS turned on",Toast.LENGTH_LONG).show();
        }

    }

This is my receiver .

    public class GpsReceiver extends BroadcastReceiver {
@Override
public void onReceive(final Context context, Intent intent) {
    int delay = 5000; // delay for 5 sec.
    //int period = 1000 *60*5; // repeat every 5min.
    int period = 30000; // repeat every 5min.

    //TO-REMOVE -TESTING PURPOSE
     Intent serviceIntent = new Intent(context,UploadService.class);
     context.startService(serviceIntent);

     if ("android.intent.action.BOOT_COMPLETED".equals(intent.getAction())) {
        Timer timer = new Timer();

        timer.scheduleAtFixedRate(new TimerTask() {
        public void run() {
            System.out.println(" Receiver done");
            Intent serviceIntent = new Intent(context,UploadService.class);
            context.startService(serviceIntent);
        }

        }, delay, period);
    }
}

}

This is my service.

   public class UploadService extends Service{
private Thread serviceThread = null;
public static final String APPURL = "http://124.43.25.10:8080/Ornox/GPSPulseReceiver";

public static double longitude;
public static  double latitude ;

@Override
public IBinder onBind(Intent arg0) {
    // TODO Auto-generated method stub
    return null;
}

@Override
public void onCreate() {
    Log.d("========", "onCreate");
    Toast.makeText(UploadService.this, "Upload GPS Service Created", Toast.LENGTH_LONG).show();

}

@Override
public void onDestroy() {
    Toast.makeText(UploadService.this, "Upload Service Stopped", Toast.LENGTH_LONG).show();
}

@Override
public void onStart(Intent intent, int startid) {
    Toast.makeText(UploadService.this, "Upload Service Started", Toast.LENGTH_LONG).show();

    ConnectivityManager manager = (ConnectivityManager) getSystemService(MassGPSTrackingActivity.CONNECTIVITY_SERVICE);
    boolean is3g = manager.getNetworkInfo(ConnectivityManager.TYPE_MOBILE).isConnectedOrConnecting();
    boolean isWifi = manager.getNetworkInfo(ConnectivityManager.TYPE_WIFI).isConnectedOrConnecting();
    if(is3g ||isWifi){
        if(!APPURL.equals("")){
            serviceThread = new ServiceThread();
            serviceThread.start();

        }
    }else {
        Toast.makeText(this, "GPRS/WIFI is not available", Toast.LENGTH_LONG).show();
    }

}


public void uploadGPSData() {
    GPSDBAdapter gpsAdapter = GPSDBAdapter.getDBAdapterInstance(this);
    gpsAdapter.openDataBase();
    try{
        String query = " SELECT ExecutiveCode,CaptureDate,CaptureTime,Longitude,Latitude" +//4
                        " FROM WMLiveGPSData " +
                        " WHERE UploadFlag ='1' ";
         ArrayList<?> stringList = gpsAdapter.selectRecordsFromDBList(query, null);
         System.out.println("==WMLiveGPSData==stringList=="+stringList.size());
         gpsAdapter.close();
         if(stringList.size() > 0){
             for (int i = 0; i < stringList.size(); i++) {
                 ArrayList<?> arrayList = (ArrayList<?>) stringList.get(i);
                 ArrayList<?> list = arrayList;
                 HttpResponse response = null;

                    ArrayList<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
                    nameValuePairs.add(new BasicNameValuePair("repc", (String)list.get(0)));
                    nameValuePairs.add(new BasicNameValuePair("rouc", "SE0160"));
                    nameValuePairs.add(new BasicNameValuePair("Date", (String)list.get(1)));
                    nameValuePairs.add(new BasicNameValuePair("Time", (String)list.get(2)));
                    nameValuePairs.add(new BasicNameValuePair("long", (String)list.get(3)));
                    nameValuePairs.add(new BasicNameValuePair("lat", (String)list.get(4)));
                    try {
                        HttpParams httpParameters = new BasicHttpParams();
                        int timeoutConnection = 3000000;
                        HttpConnectionParams.setConnectionTimeout(httpParameters,timeoutConnection);
                        int timeoutSocket = 5000000; // in milliseconds which is the timeout                                
                        HttpConnectionParams.setSoTimeout(httpParameters, timeoutSocket);
                        HttpClient httpclient = new DefaultHttpClient(httpParameters);
                        HttpPost method = new HttpPost(APPURL);
                        // method.setHeader("Content-Type","text/xml");

                        method.setEntity(new UrlEncodedFormEntity(nameValuePairs));
                        response = httpclient.execute(method);
                        System.out.println("==response==" + response);
                        if (response != null) {
                            Log.i("login",""+ response.getEntity().getContentLength());
                        } else {
                            Log.i("login", "got a null response");
                        }

                    } catch (ClientProtocolException e) {
                        e.printStackTrace();
                    } catch (IOException e) {
                        e.printStackTrace();
                    } catch (Exception e) {
                        Toast.makeText(getApplicationContext(),
                                "Could not connect to server. Please Try again",
                                Toast.LENGTH_SHORT).show();
                        Log.e("log_tag", "Error in http connection " + e.toString());
                    }
             }

         }
    }catch (Exception e) {
        e.printStackTrace();
    }

    //return response;
}

private class ServiceThread extends Thread {
    @Override
    public void run() {
          uploadGPSData();
    }   
};

}

This is my manifest file

     <application
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name" >
    <activity
        android:name=".MassGPSTrackingActivity"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

     <activity android:name=".HomeActivity"   android:screenOrientation="unspecified"></activity>
     <service android:enabled="true" android:name=".service.UploadService" />

    <receiver android:name="com.mass.gps.service.GpsReceiver">
        <intent-filter>
            <action android:name="android.intent.action.BOOT_COMPLETED" />
            <action android:name="android.intent.action.BATTERY_CHANGED" />
            <action android:name="android.intent.action.ACTION_POWER_CONNECTED"/>
             <action android:name="android.intent.action.SCREEN_ON"/>
            <action android:name="android.intent.action." />
        </intent-filter>
    </receiver>

</application>

 <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
 <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
 <uses-permission android:name="android.permission.ACCESS_GPS"></uses-permission>
 <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
 <uses-permission android:name="android.permission.READ_PHONE_STATE" />

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WAKE_LOCK"/>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

Issue is it didn’t go to Service class.

Please help me out this question…

Thanks in advance..

  • 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-02T17:02:10+00:00Added an answer on June 2, 2026 at 5:02 pm

    i think u r package name is not correct manifest file

      <service android:enabled="true" android:name="com.mass.gps.service.UploadService" />
    

    specify your service name as packagename

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

Sidebar

Related Questions

Does every j2me enabled mobile have GPS service so that the developer can locate
I have a thread that sends GPS coordinates to a database every six seconds
I'm working on asset tracking application. I have devices that send update on GPS
We are developing a vehicle tracking system. Like every VTS, we have GPS devices
I have read up on GPS Real time tracking and found out several things
InstaMapper is a GPS tracking service that updates the device's position more frequently when
The application that I have in the works uses GPS data to mark files
We have a vehicle tracking system. We are using MySQL as database server. One
I have a gps time in the database,and when I do some query,I have
I have built a GPS tracker that updates a homepage with its positions (and

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.