diff --git a/src/main/java/eu/siacs/conversations/ui/ShareLocationActivity.java b/src/main/java/eu/siacs/conversations/ui/ShareLocationActivity.java
index ee1d525a1..aa02bf1c5 100644
--- a/src/main/java/eu/siacs/conversations/ui/ShareLocationActivity.java
+++ b/src/main/java/eu/siacs/conversations/ui/ShareLocationActivity.java
@@ -29,6 +29,7 @@ import java.util.Locale;
import eu.siacs.conversations.R;
import eu.siacs.conversations.utils.LocationHelper;
import eu.siacs.conversations.utils.ThemeHelper;
+import me.drakeet.support.toast.ToastCompat;
public class ShareLocationActivity extends LocationActivity implements LocationListener {
@@ -211,20 +212,25 @@ public class ShareLocationActivity extends LocationActivity implements LocationL
}
private void showLocation(@Nullable Location location, String address) {
- if (location == null && TextUtils.isEmpty(address)) { // no location and no address available
- final WebView webView = findViewById(R.id.webView);
- webView.getSettings().setJavaScriptEnabled(true);
- webView.loadUrl("file:///android_asset/map.html");
- } else if (location != null && TextUtils.isEmpty(address)) { // location but no address available
- String LocationName = "" + mLocationName + "";
- final WebView webView = findViewById(R.id.webView);
- webView.getSettings().setJavaScriptEnabled(true);
- webView.loadUrl("javascript:toCoordinates(" + mLastLocation.getLatitude() + "," + mLastLocation.getLongitude() + "," + "'" + LocationName + "'" +");");
- } else if (location != null && !TextUtils.isEmpty(address)) { // location and address available
- String LocationName = "" + mLocationName + "
" + address;
- final WebView webView = findViewById(R.id.webView);
- webView.getSettings().setJavaScriptEnabled(true);
- webView.loadUrl("javascript:toCoordinates(" + mLastLocation.getLatitude() + "," + mLastLocation.getLongitude() + "," + "'" + LocationName + "'" +");");
+ try {
+ if (location == null && TextUtils.isEmpty(address)) { // no location and no address available
+ final WebView webView = findViewById(R.id.webView);
+ webView.getSettings().setJavaScriptEnabled(true);
+ webView.loadUrl("file:///android_asset/map.html");
+ } else if (location != null && TextUtils.isEmpty(address)) { // location but no address available
+ String LocationName = "" + mLocationName + "";
+ final WebView webView = findViewById(R.id.webView);
+ webView.getSettings().setJavaScriptEnabled(true);
+ webView.loadUrl("javascript:toCoordinates(" + mLastLocation.getLatitude() + "," + mLastLocation.getLongitude() + "," + "'" + LocationName + "'" + ");");
+ } else if (location != null && !TextUtils.isEmpty(address)) { // location and address available
+ String LocationName = "" + mLocationName + "
" + address;
+ final WebView webView = findViewById(R.id.webView);
+ webView.getSettings().setJavaScriptEnabled(true);
+ webView.loadUrl("javascript:toCoordinates(" + mLastLocation.getLatitude() + "," + mLastLocation.getLongitude() + "," + "'" + LocationName + "'" + ");");
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ ToastCompat.makeText(this, R.string.error, ToastCompat.LENGTH_LONG);
}
}
diff --git a/src/main/java/eu/siacs/conversations/ui/ShowLocationActivity.java b/src/main/java/eu/siacs/conversations/ui/ShowLocationActivity.java
index ddfbf64d4..ad0dbef9c 100644
--- a/src/main/java/eu/siacs/conversations/ui/ShowLocationActivity.java
+++ b/src/main/java/eu/siacs/conversations/ui/ShowLocationActivity.java
@@ -17,7 +17,6 @@ import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.webkit.WebView;
-import android.widget.Toast;
import com.google.android.material.floatingactionbutton.FloatingActionButton;
@@ -137,16 +136,21 @@ public class ShowLocationActivity extends XmppActivity {
}
private void showLocation(Location location, String address) {
- if (location != null && TextUtils.isEmpty(address)) { // location but no address available
- String LocationName = "" + mLocationName + "";
- final WebView webView = findViewById(R.id.webView);
- webView.getSettings().setJavaScriptEnabled(true);
- webView.loadUrl("file:///android_asset/map.html?lat=" + location.getLatitude() + "&lon=" + location.getLongitude() + "&name=" + LocationName);
- } else if (location != null && !TextUtils.isEmpty(address)) { // location and address available
- String LocationName = "" + mLocationName + "
" + address;
- final WebView webView = findViewById(R.id.webView);
- webView.getSettings().setJavaScriptEnabled(true);
- webView.loadUrl("javascript:toCoordinates(" + location.getLatitude() + "," + location.getLongitude() + "," + "'" + LocationName + "'" +");");
+ try {
+ if (location != null && TextUtils.isEmpty(address)) { // location but no address available
+ String LocationName = "" + mLocationName + "";
+ final WebView webView = findViewById(R.id.webView);
+ webView.getSettings().setJavaScriptEnabled(true);
+ webView.loadUrl("file:///android_asset/map.html?lat=" + location.getLatitude() + "&lon=" + location.getLongitude() + "&name=" + LocationName);
+ } else if (location != null && !TextUtils.isEmpty(address)) { // location and address available
+ String LocationName = "" + mLocationName + "
" + address;
+ final WebView webView = findViewById(R.id.webView);
+ webView.getSettings().setJavaScriptEnabled(true);
+ webView.loadUrl("javascript:toCoordinates(" + location.getLatitude() + "," + location.getLongitude() + "," + "'" + LocationName + "'" + ");");
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ ToastCompat.makeText(this, R.string.error, ToastCompat.LENGTH_LONG);
}
}
@@ -162,7 +166,7 @@ public class ShowLocationActivity extends XmppActivity {
startActivity(intent);
overridePendingTransition(R.animator.fade_in, R.animator.fade_out);
} catch (ActivityNotFoundException e) {
- ToastCompat.makeText(this, R.string.no_application_found_to_display_location, Toast.LENGTH_SHORT).show();
+ ToastCompat.makeText(this, R.string.no_application_found_to_display_location, ToastCompat.LENGTH_SHORT).show();
}
}