Skip to content

Commit 0131c44

Browse files
committed
Prevent crash on showing AlertDialogWpp
Before showing an `AlertDialogWpp`, check if the underlying `Activity` context is finishing or destroyed to prevent a `WindowManager$BadTokenException`. Signed-off-by: Dev4Mod <[email protected]>
1 parent 806333e commit 0131c44

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

app/src/main/java/com/wmods/wppenhacer/xposed/core/components/AlertDialogWpp.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.wmods.wppenhacer.xposed.core.components;
22

3+
import android.app.Activity;
34
import android.app.AlertDialog;
45
import android.app.Dialog;
56
import android.content.Context;
@@ -178,6 +179,12 @@ public void dismiss() {
178179
}
179180

180181
public void show() {
182+
if (mContext instanceof Activity) {
183+
Activity activity = (Activity) mContext;
184+
if (activity.isFinishing() || activity.isDestroyed()) {
185+
return;
186+
}
187+
}
181188
if (isSystemDialog()) {
182189
mAlertDialog.show();
183190
return;

0 commit comments

Comments
 (0)