GPS default value



  • There's GPS data that's reflected in latitude. 56,1922 and longitudes 37,8615♪ When the GPS receiver turns off the result null null♪ There's a desire to change this result when the switch is off. 00,0000 00,0000but something doesn't work out the same way.

    That's the code. null null

    private void showLocation(Location location) {
        if (location == null)
            return;
    
    dataGPS1 = formatLocation1(location);
    dataGPS2 = formatLocation2(location);
    

    }

    public String formatLocation1(Location location) {// НА ВХОД БЕРЁТ Location location
    if (location == null) //ЧЕТАЕТ ИЗ НЕГО ДАННЫЕ И ВЫДАЁТ СТРОКУ
    return ""; //ШИРОТА, ДОЛГОТА, ВРЕМЯ ОПРЕДЕЛЕНИЯ
    return String.format(
    "%1$.4f",
    location.getLatitude(), location.getLongitude());

    }

    public String formatLocation2(Location location) {// НА ВХОД БЕРЁТ Location location
    if (location == null) //ЧЕТАЕТ ИЗ НЕГО ДАННЫЕ И ВЫДАЁТ СТРОКУ
    return ""; //ШИРОТА, ДОЛГОТА, ВРЕМЯ ОПРЕДЕЛЕНИЯ
    return String.format(
    "%2$.4f",
    location.getLatitude(), location.getLongitude());

    }

    Trying to fix the same thing.

    private void showLocation(Location location) {
    if (formatLocation1(location).equals("null")){
    dataGPS1="00,0000"; ;
    }else{
    dataGPS1 = formatLocation1(location);
    }

    if (formatLocation2(location).equals("null")){
        dataGPS2="00,0000";
    }else{
        dataGPS2 = formatLocation2(location);
    }
    

    }



  • Fix the function. formatLocation1() and formatLocation2()

    if (location == null)                         
        return "00.0000";  
    

    From showLocation() Remove the test. null




Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2