I am trying to let the user select shipping address through google maps. The coordinates selected needs to be displayed in a text view. I'm using intents to return the selected coordinates to the previous activity but the problem is that no matter what I try the intent is returning null every time.
This is button click event that should put the coordinates inside the intent:
AddressSelectActivity.java
confirm.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent();
intent.putExtra("Latitude", latitude);
setResult(RESULT_OK, intent);
finish();
}
});
I'm retrieving the values onResume():
Register.java
shipping.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent mapsActivity = new Intent(v.getContext(), AddressSelectActivity.class);
startActivityForResult(mapsActivity, 1);
}
});
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
Toast.makeText(this, "Inside onActivityResult", Toast.LENGTH_SHORT).show();
if (requestCode == 1) {
if(resultCode == RESULT_OK) {
Toast.makeText(this, data.getStringExtra("Latitude"), Toast.LENGTH_SHORT).show();
shipping.setText(data.getStringExtra("Latitude"));
}
}
}
Can anyone provide any guidance. Thank You!