Closed TieuNhi95 closed 6 years ago
Hi @TieuNhi95 ,
Yes, it's unfortunate but your Activity
is not started when reaching onActivityResult
, meaning that your mView
variable will be null into your Presenter
.
You should always ensure you handle those cases with something like that :
public class MyPresenter extends BasePresenterImpl {
@Nullable
private Stuff mTempResult;
@Override
public void onStart(boolean viewCreated) {
// ... Your usual code here
if( mTempResult != null ) {
// Handle your result
mTempResult = null;
}
}
public void onOtherActivityResult(@NonNull Stuff result) {
if( mView != null ) {
// Handle your result directly here
} else {
mTempResult = result;
}
}
}
This way you ensure that your result will be handled either right away if the view is available, or at the next start otherwise.
Let me know if it's unclear.
thanks, i got it (y)
thanks for your template but i have a problem with mPresenter and mView sometime ,its return null in onActivityResult.