Here I have tried to pass the some value to 2nd activity(Child) to 1st activity(Parent). I have noted that in API-21 above version of device onActivityResult is called but for API-19 and below of it, it is not called. Here I share snippets of my code.Please check it.
Your answer is more appreciated!!!
In parent activity:
STEP 1
Intent intent = new Intent(ABCAct.this, DEF.class);
intent.putExtra("mapPickDrop", "1");
intent.putExtra("location_lat", P_latitude);
intent.putExtra("location_lng", P_longitude);
intent.putExtra("address", pickupAddressFlag);
startActivityForResult(intent, 2018);
STEP 2:
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == 2018) {
if (resultCode == RESULT_OK) {
Double lat = data.getDoubleExtra("location_lat", 0.0);
Double lng = data.getDoubleExtra("location_lng", 0.0);
String add = data.getStringExtra("location_address");
String mapPickDrop = data.getStringExtra("mapPickDrop");
if (mapPickDrop.equals("1")) {
P_latitude = lat;
P_longitude = lng;
pickupAddressFlag = add;
TaxiUtil.bookTaxiPickUpDrop = 1;
if (P_latitude != 0.0 && P_longitude != 0.0 && D_latitude == 0.0 && D_longitude == 0.0) {
setLocation(P_latitude, P_longitude, "");
}
}
if (mapPickDrop.equals("2")) {
TaxiUtil.bookTaxiPickUpDrop = 2;
D_latitude = lat;
D_longitude = lng;
DroplocEdt.setText("" + add);
showPickupDropMarkers();
}
}
}
}
In Child activity
Intent back = new Intent();
back.putExtra("location_lat", P_latitude_new);
back.putExtra("location_lng", P_longitude_new);
back.putExtra("location_address", PicklocEdt_1.getText().toString());
back.putExtra("mapPickDrop", mapPickDrop);
setResult(RESULT_OK, back);
finish();
Manifest
<activity
android:name=".ABCAct"
android:configChanges="orientation|keyboardHidden"
android:launchMode="singleTask"
android:screenOrientation="portrait"
android:windowSoftInputMode="stateHidden|stateAlwaysHidden">
<activity
android:name=".DEF"
android:configChanges="orientation|keyboardHidden"
android:launchMode="singleTask"
android:screenOrientation="portrait"
android:windowSoftInputMode="stateHidden|stateAlwaysHidden" />
1:Deleting android:noHistory="true"
from the activity I was having problem with solved the issue for me
2: Change if you have android:launchMode=“singleTask”
to android:launchMode=“standard”
hope it helps!!!!