I try to get the result in a fragment. Code in fragment
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
if (resultCode != Activity.RESULT_OK) return
val bundle = data?.extras
when (requestCode) {
LicenseActivationActivity.REQUEST_RESULT_COUNT_ENTERPRISE ->
//
}
}
This code is called. But also method onActivityResult in DrawerActivity
Do that onActivityResult is called only in the fragment?
UPDATE
This code in DrawerActivity
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
if (resultCode == Activity.RESULT_OK) {
WayBillsActivity.start(this)
finish()
}
}
For some reason, it is also satisfied, but only after onActivityResult in fragment.
in your Activity call this
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
for (Fragment fragment : getSupportFragmentManager().getFragments()) {
fragment.onActivityResult(requestCode, resultCode, data);
}
}
Then call in fragment
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
//super.onActivityResult(requestCode, resultCode, data); comment this unless you
}
add code in Drawer activity
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
fragment.super.onActivityResult(requestCode, resultCode, data)
}
**fragment.super.onActivityResult(requestCode, resultCode, data)**
Then your onActivityResult
method of fragment called
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