aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/de/pixart/messenger/persistance
diff options
context:
space:
mode:
authorChristian Schneppe <christian@pix-art.de>2018-11-30 19:23:35 +0100
committerChristian Schneppe <christian@pix-art.de>2018-11-30 19:23:35 +0100
commit964cf03653fb28f49c373421d472ae30b641b546 (patch)
treef4646c75a92c03101c84618d2e206549a8f9f33b /src/main/java/de/pixart/messenger/persistance
parent8071fb24305aaea54737efeb43b6ba03a1be034d (diff)
catch npe while detecting apk names
Diffstat (limited to 'src/main/java/de/pixart/messenger/persistance')
-rw-r--r--src/main/java/de/pixart/messenger/persistance/FileBackend.java19
1 files changed, 12 insertions, 7 deletions
diff --git a/src/main/java/de/pixart/messenger/persistance/FileBackend.java b/src/main/java/de/pixart/messenger/persistance/FileBackend.java
index 092feabe2..6ea506692 100644
--- a/src/main/java/de/pixart/messenger/persistance/FileBackend.java
+++ b/src/main/java/de/pixart/messenger/persistance/FileBackend.java
@@ -1023,20 +1023,25 @@ public class FileBackend {
private String getAPK (File file, Context context) {
String APKName;
- //final Drawable icon;
final PackageManager pm = context.getPackageManager();
final PackageInfo pi = pm.getPackageArchiveInfo(file.toString(), 0);
- pi.applicationInfo.sourceDir = file.toString();
- pi.applicationInfo.publicSourceDir = file.toString();
- //icon = pi.applicationInfo.loadIcon(pm);
- final String AppName = (String) pi.applicationInfo.loadLabel(pm);
- final String AppVersion = pi.versionName;
+ String AppName;
+ String AppVersion;
+ try {
+ pi.applicationInfo.sourceDir = file.toString();
+ pi.applicationInfo.publicSourceDir = file.toString();
+ AppName = (String) pi.applicationInfo.loadLabel(pm);
+ AppVersion = pi.versionName;
+ } catch (Exception e) {
+ e.printStackTrace();
+ AppName = String.valueOf(R.string.apk);
+ AppVersion = "0";
+ }
Log.d(Config.LOGTAG, "APK name: " + AppName);
APKName = " (" + AppName + " " + AppVersion + ")";
try {
byte[] data = APKName.getBytes("UTF-8");
APKName = Base64.encodeToString(data, Base64.DEFAULT);
-
} catch (UnsupportedEncodingException e) {
APKName = "";
e.printStackTrace();