0

I have the following sequence of events. Unable to make them run in that sequence.

This is the way it should work:

Onclick action in MainActivity opens Attendance activity Before the user clicks on Attendance, the Location from Network / GPS to be collected Load the results to public variables and compile a URL string On Click, Do a POST with the URL string

If Internet is not available, store the URL locally Once Internet is available OnClick, dump out the stored URLs in sequence, and process the current URL

What's happening:

The sequential tasks are not occurring - I'm using the code below to sequence them.

new CountDownTimer(5000, 1000) {

@Override
public void onTick(long millisUntilFinished) {
    // do something after 1s
    call networklocation();
}

@Override
public void onFinish() {
    // do something end times 5s
    call gpslocation();
}

}.start();

Then call another CountDownTimer with the next events and so on.

Can someone please help?

Sriram Nadiminti
  • 107
  • 2
  • 12

1 Answers1

0

For the location, you can use this GPSUtil class from below given link https://gist.github.com/kishandonga/fcbbe0f48899f763afd127682645218c

After successfully you got coordinate from callback do service call as you mention. Once your service gives success or fails state respectively open Attendance activity.

Kishan Donga
  • 2,851
  • 2
  • 23
  • 35
  • Thank you. How do I call this Class from Attendance activity? gpsStatus(boolean isGPSEnable)? What result is coming out of this class? How do I get the similar output for Networkbased Location? – Sriram Nadiminti Sep 21 '20 at 14:54
  • Also, when I added the code into a class, I'm getting the error "Lambda expressions are not supported at language level '7'" at "locationSettingsResponse". and error on Const.GPS_REQUEST - Cannot resolve symbol 'Const' – Sriram Nadiminti Sep 21 '20 at 15:02
  • Provide Java 8 Support in your Gradle refer this answer https://stackoverflow.com/a/43237601/6370015 – Kishan Donga Sep 22 '20 at 04:32