Prevent crash if no dashboard is installed.

This commit is contained in:
Dennis Guse
2022-06-27 19:33:24 +02:00
parent 5fa50250de
commit 92f6fbe04a
2 changed files with 9 additions and 1 deletions
@@ -1,11 +1,13 @@
package de.dennisguse.opentracks.util;
import android.content.ActivityNotFoundException;
import android.content.ClipData;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.util.Log;
import android.util.Pair;
import android.widget.Toast;
import androidx.appcompat.app.AlertDialog;
@@ -173,7 +175,12 @@ public class IntentDashboardUtils {
Log.i(TAG, "Starting dashboard activity with generic intent (package=" + targetPackage + ", class=" + targetClass + ")");
}
context.startActivity(intent);
try {
context.startActivity(intent);
} catch (ActivityNotFoundException e) {
Log.e(TAG, "Dashboard not installed; cannot start it.");
Toast.makeText(context, R.string.show_on_dashboard_not_installed, Toast.LENGTH_SHORT).show();
}
}
/**