From cb911e3402313fee7565b7a198dff301a6215cdb Mon Sep 17 00:00:00 2001 From: Zhendong Yang Date: Thu, 24 Mar 2016 10:54:49 +0800 Subject: [PATCH] Fix crash when rotating HighPowerDetail dialog When rotating the device, the Activity of the target Fragment become null. So NullPointerException occurs. The dialog should check if the Activity is null before calling onActivityResult(). Bug: 28333723 Test: manual - go to Settings > Apps > Clock, click Battery optimization and rotate device Change-Id: I7f68d6ece7d169fd96d04c1788e55ee506aae1ae --- src/com/android/settings/fuelgauge/HighPowerDetail.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/com/android/settings/fuelgauge/HighPowerDetail.java b/src/com/android/settings/fuelgauge/HighPowerDetail.java index 6946f62f18e..daa72daab78 100644 --- a/src/com/android/settings/fuelgauge/HighPowerDetail.java +++ b/src/com/android/settings/fuelgauge/HighPowerDetail.java @@ -131,7 +131,7 @@ public class HighPowerDetail extends DialogFragment implements OnClickListener, public void onDismiss(DialogInterface dialog) { super.onDismiss(dialog); Fragment target = getTargetFragment(); - if (target != null) { + if (target != null && target.getActivity() != null) { target.onActivityResult(getTargetRequestCode(), 0, null); } }