Отправляет данные со 2й попытки в другой activity

Столкнулся со странностей, при запуске Activity определяются координаты и присваиваются в edCollectionGPSLat,edCollectionGPSLon,edCollectionNWLat,edCollectionNWLon при нажатии на кнопку они отправляются в другой Activity, но туда приходит null. При условии того что данные уже вычисленные и присвоены. Прошу подскажите из-за чего так происходит.

Часть кода с обработчиком нажатия

public View onCreateView(
            LayoutInflater inflater, ViewGroup container,
            Bundle savedInstanceState
    ) {
...
        edCollectionNWLat = view.findViewById(R.id.edCollectionNWLat);
        edCollectionNWLon = view.findViewById(R.id.edCollectionNWLon);
        edCollectionGPSLat = view.findViewById(R.id.edCollectionGPSLat);
        edCollectionGPSLon = view.findViewById(R.id.edCollectionGPSLon);
...
 buttonCustAccountByGPS.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                if (edCollectionNWLat.getText().length() == 0) {
                    Toast.makeText(getContext(), "Определение координат", Toast.LENGTH_LONG).show();
                    return;
                }

                Intent intent = new Intent(context, DeterminationOfCoordinates.class);
                itemSelect = true;

                if (edCollectionGPSLat.getText().length() > 0) {
                    intent.putExtra("LAT", Double.valueOf(edCollectionGPSLat.getText().toString()));
                    intent.putExtra("LON", Double.valueOf(edCollectionGPSLon.getText().toString()));
                } else if (edCollectionNWLat.getText().length() > 0) {
                    intent.putExtra("LAT", Double.valueOf(edCollectionNWLat.getText().toString()));
                    intent.putExtra("LON", Double.valueOf(edCollectionNWLon.getText().toString()));
                }

                
                startActivityForResult(intent, REQUEST_CODE_CUST);

                edCollectionNWLat.setText("");
                edCollectionNWLon.setText("");

                edCollectionGPSLat.setText("");
                edCollectionGPSLon.setText("");

                locationManager.removeUpdates(locationListener);
                resumeLocationUpdates();

            }
        });
...

tableToControl(false);
}

tableToControl

void tableToControl(boolean onlyCalc) {
        if (!onlyCalc) {
            tvCustAccount.setText(Global.collectionTable.getCustAccount());
        }


        edCollectionGPSLat.setText(String.valueOf(Global.collectionTable.getGPSLat()));
        edCollectionGPSLon.setText(String.valueOf(Global.collectionTable.getGPSLon()));

        edCollectionNWLat.setText(String.valueOf(Global.collectionTable.getNWLat()));
        edCollectionNWLon.setText(String.valueOf(Global.collectionTable.getNWLon()));
    }

Activity2

protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.determination_of_coordinates);
        this.setTitle(String.format("Клиенты в радиусе %d метров", RADIUS));
        custs = new ArrayList<TCust>();
        double lat = this.getIntent().getDoubleExtra("LAT", 0);
        double lon = this.getIntent().getDoubleExtra("LON", 0);
        fillArray(lat, lon, RADIUS);
        lvCustNearest = findViewById(R.id.lvCustNearest);
        arrayAdapter = new CustAdapter(this);
        lvCustNearest.setAdapter(arrayAdapter);
        lvCustNearest.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                Intent intent = new Intent();
                TCust cust = custs.get((int) id);
                long _id = cust.id;
                intent.putExtra("CustAccount", cust.CustAccount);
                intent.putExtra("_id", _id);
                setResult(RESULT_OK, intent);
                finish();
            }
        });
        if (lat == 0 || lon == 0) {
            finish();
        }
    }

На данном фото координаты определились. введите сюда описание изображения

При нажатии на кнопку 1 раз ( при условии что координаты определенны и присвоены) они не передаются введите сюда описание изображения

При втором нажатии ( когда данные переопределяются) все передает введите сюда описание изображения


Ответы (0 шт):