forked from upstream-mirrors/OpenTracks
Prevent crash if no dashboard is installed.
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -666,5 +666,6 @@ limitations under the License.
|
||||
<string name="select_show_on_map_behavior">Select \"show on map\" behavior</string>
|
||||
<string name="show_on_map_format_ask">Ask</string>
|
||||
<string name="show_on_dashboard">OpenTracks Dashboard API</string>
|
||||
<string name="show_on_dashboard_not_installed">No application supporting OpenTracks Dashboard API installed.</string>
|
||||
<string name="always">Always</string>
|
||||
</resources>
|
||||
|
||||
Reference in New Issue
Block a user