In my android app, I have a main activity which creates two other sub activites through intent. Now, both the sub activity return result to the main activity. In my main activity, how do I handle two "onActivityResult(int requestCode, int resultCode, Intent data)" since it cant have two methods with same name in a given class. Hope my question is clear..
Thanks
You change the requestCode
that you use when you call startActivityForResult
.
EDIT: for example, I use this:
startActivityForResult(i, App.REQUEST_ENABLE_BT);
and this:
startActivityForResult(i, App.MANUAL_INPUT);
and then you filter the results like this:
protected void onActivityResult(int requestCode, int resultCode, Intent data)
{
super.onActivityResult(requestCode, resultCode, data);
if(resultCode == RESULT_OK){
switch(requestCode){
case App.REQUEST_ENABLE_BT:
if(resultCode != RESULT_OK){
Toast.makeText(this, getString(R.string.label_bluetooth_disabled), Toast.LENGTH_LONG).show();
}
break;
case App.MANUAL_INPUT:
break;
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With