From 357c7f894fc9bea82b9980ab79ac88419934cae7 Mon Sep 17 00:00:00 2001 From: jens <android-development@gmx.de> Date: Thu, 13 May 2021 12:06:15 +0200 Subject: [PATCH] Crash resolved when trying display an unknown translation for a permission --- .../jens/automation2/ActivityPermissions.java | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/com/jens/automation2/ActivityPermissions.java b/app/src/main/java/com/jens/automation2/ActivityPermissions.java index 113b51f6..00f0b2c9 100644 --- a/app/src/main/java/com/jens/automation2/ActivityPermissions.java +++ b/app/src/main/java/com/jens/automation2/ActivityPermissions.java @@ -7,6 +7,7 @@ import android.content.Context; import android.content.Intent; import android.content.pm.PackageInfo; import android.content.pm.PackageManager; +import android.content.res.Resources; import android.net.Uri; import android.os.Build; import android.os.Bundle; @@ -189,14 +190,19 @@ public class ActivityPermissions extends Activity } else { - explanation.append( + explanation.append("<br /><u>"); - "<br />" + - "<u>" + - getResources().getString(getResources().getIdentifier(s, "string", getPackageName())) - + "</u>" + try + { + explanation.append(getResources().getString(getResources().getIdentifier(s, "string", getPackageName()))); + } + catch(Resources.NotFoundException e) + { + Miscellaneous.logEvent("w", "ActivityPermissions", "Could not find translation for " + s, 4); + explanation.append(s); + } - + "<br />"); + explanation.append("</u><br />"); for (String reason : getReasonForPermission(s)) explanation.append(reason + "<br />");