Android: Don't crash if there is no web browser installed (#14683)

This commit is contained in:
grorp 2024-05-26 19:49:32 +02:00 committed by GitHub
parent 83bc362dac
commit b1fa430dad
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 8 additions and 1 deletions

@ -23,6 +23,7 @@ package net.minetest.minetest;
import org.libsdl.app.SDLActivity;
import android.content.Intent;
import android.content.ActivityNotFoundException;
import android.net.Uri;
import android.os.Bundle;
import android.text.InputType;
@ -33,6 +34,7 @@ import android.view.WindowManager;
import android.view.inputmethod.InputMethodManager;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.Toast;
import android.content.res.Configuration;
import androidx.annotation.Keep;
@ -201,7 +203,11 @@ public class GameActivity extends SDLActivity {
public void openURI(String uri) {
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(uri));
startActivity(browserIntent);
try {
startActivity(browserIntent);
} catch (ActivityNotFoundException e) {
runOnUiThread(() -> Toast.makeText(this, R.string.no_web_browser, Toast.LENGTH_SHORT).show());
}
}
public String getUserDataPath() {

@ -7,4 +7,5 @@
<string name="unzip_notification_title">Loading Minetest</string>
<string name="unzip_notification_description">Less than 1 minute&#8230;</string>
<string name="ime_dialog_done">Done</string>
<string name="no_web_browser">No web browser found</string>
</resources>