I have an app wherein there are two dropdown's. The first is for "Society" and the second one is for "house numbers". The "house numbers" dropdown is populated based on the "Society" selected.
The problem I am facing is that in few phone's, when user selects the "House Number", the "Society" dropdown is reset to blank value. I don't understand how is this possible as I have not updated society dropdown on house number selection and this is happening in few phones only out of almost 100 I have tested.
Here is my code.
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
// Check which request we're responding to
if (requestCode == Society_REQUEST) {
// Make sure the request was successful
if (resultCode == RESULT_OK) {
// The user picked a contact.
// The Intent's data Uri identifies which contact was selected.
try {
String cityObj = data.getExtras().getString("cityObj");
CommonClass.writelog(tag,
"onActivityResult()102 Reqestcode:" + requestCode
+ " ResultCode:" + resultCode + " data:"
+ data.getStringExtra("cityObj"));
try {
JSONObject cObj = new JSONObject(cityObj);
// common.setSession("selected_city_id",cObj.getString("Id"));
TextView txtSocity = (TextView) findViewById(R.id.txtSocity);
CommonClass
.writelog(tag,
"onActivityResult()109:Society_REQUEST: txtSocity TextView Variable Create:");
txtSocity.setText(cObj.getString("Name"));
CommonClass.writelog(tag,
"onActivityResult()111:Society_REQUEST: txtSocity.setText:"
+ cObj.getString("Name")
+ " txtSocity.getText:"
+ txtSocity.getText().toString());
socity_id = cObj.getString("Id");
CommonClass.writelog(tag,
"onActivityResult()114:Society_REQUEST: socity_id:"
+ cObj.getString("Id"));
} catch (JSONException e) {
CommonClass.writelog(
tag,
"onActivityResult()117:Society_REQUEST: Reqestcode:"
+ requestCode + " ResultCode:"
+ resultCode + " data:"
+ data.getStringExtra("cityObj") + "\n"
+ e.getMessage());
e.printStackTrace();
}
// Do something with the contact here (bigger example below)
} catch (Exception ex) {
String cityObj = data.getExtras().getString("cityObjOther");
CommonClass.writelog(
tag,
"onActivityResult()102 Reqestcode:" + requestCode
+ " data:"
+ data.getStringExtra("cityObjOther"));
try {
flg = 1;
String[] tmep = cityObj.split("##");
TextView txtSocity = (TextView) findViewById(R.id.txtSocity);
txtSocity.setText(tmep[1].toString());
socity_id = tmep[0].toString();
} catch (Exception e) {
e.printStackTrace();
}
}
}
} else if (requestCode == Homeno_REQUEST) {
// Make sure the request was successful
if (resultCode == RESULT_OK) {
// Make sure the request was successful
if (resultCode == RESULT_OK) {
// The user picked a contact.
// The Intent's data Uri identifies which contact was
// selected.
try {
String cityObj1 = data.getExtras().getString("homeObj");
try {
JSONObject cObj = new JSONObject(cityObj1);
TextView txtHomeNo = (TextView) findViewById(R.id.txtHomeno);
txtHomeNo.setText(cObj.getString("Name"));
home_id = cObj.getString("Id");
} catch (JSONException e) {
e.printStackTrace();
}
// Do something with the contact here (bigger example
// below)
} catch (Exception ex) {
String cityObj = data.getExtras().getString(
"homeObjOther");
try {
flg = 1;
String[] tmep = cityObj.split("##");
TextView txtHomeNo = (TextView) findViewById(R.id.txtHomeno);
txtHomeNo.setText(tmep[1].toString());
home_id = tmep[0].toString();
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
}
listView.setAdapter(selectHomenoAdapter);
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
Intent returnIntent = getIntent();
returnIntent.putExtra("homeObj",
selectHomenoAdapter.getItem(position).toString());
setResult(RESULT_OK, returnIntent);
finish();
}
});
}