From 10498ce1a43a5c093271de7ff409408b96b50da4 Mon Sep 17 00:00:00 2001 From: Sylvia van Os Date: Wed, 16 Nov 2022 21:42:52 +0100 Subject: [PATCH] Prevent NullPointerException in onBackPressed This crash seems to somehow only happen on Huawei and Xiaomi devices. While fairly rare, it is the most common Catima crash currently logged on Google Play Console (8 crashes over the last 28 days). While I don't understand how this would happen, I think it should be relatively safe to assume that if the searchview is null the user isn't currently searching so running the normal back code should always be the expected behaviour. --- app/src/main/java/protect/card_locker/MainActivity.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/protect/card_locker/MainActivity.java b/app/src/main/java/protect/card_locker/MainActivity.java index 838be16ee..2546d2ae1 100644 --- a/app/src/main/java/protect/card_locker/MainActivity.java +++ b/app/src/main/java/protect/card_locker/MainActivity.java @@ -425,7 +425,7 @@ public class MainActivity extends CatimaAppCompatActivity implements LoyaltyCard @Override public void onBackPressed() { - if (!mSearchView.isIconified()) { + if (mSearchView != null && !mSearchView.isIconified()) { mSearchView.setIconified(true); return; }