Skip to content

add check if getActivity() == null#151

Open
bso112 wants to merge 1 commit intoParkSangGwon:masterfrom
bso112:handle_configuration_change
Open

add check if getActivity() == null#151
bso112 wants to merge 1 commit intoParkSangGwon:masterfrom
bso112:handle_configuration_change

Conversation

@bso112
Copy link

@bso112 bso112 commented Jun 15, 2022

TedBottomPicker uses ProxyActivity. and ProxyActivity stores ActivityRequest.
So if configuration change occurs, ActivityRequest's OnActivityResultListener reference destroyed TedBottomSheetDialogFragment.
This causes runtime Exception.

Failure delivering result ResultInfo{who=null, request=3457, result=-1, data=Intent { dat=content://media/external/images/media/7356 flg=0x1 (has extras) }} to activity {com.sample.android.demo/com.gun0912.tedonactivityresult.ProxyActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.pm.PackageManager android.content.Context.getPackageManager()' on a null object reference

You can demonstrate this problem by enabling 'Don't keep activities' on the Developer Options In Android Phone Setting.

To solve this problem, we can either check getActivity() != null when invoking onActivityResult() or make ProxyActivity doesn't stores ActivityRequest. The former will skip processing the Activity result, but Runtime Exception will not occur. The Latter takes so many changes. So, I choose the former.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant