Fix a crash when there's no web browser installed

Signed-off-by: Alexander Ivanov <vanogrid@gmail.com>
This commit is contained in:
Alexander Ivanov
2022-09-04 01:58:04 +03:00
parent 625ea26b0a
commit 68a24fae2f
3 changed files with 10 additions and 1 deletions

View File

@@ -1,5 +1,6 @@
package protect.card_locker;
import android.content.ActivityNotFoundException;
import android.content.Intent;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
@@ -9,6 +10,7 @@ import android.util.Log;
import android.view.MenuItem;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;
import java.io.BufferedReader;
import java.io.IOException;
@@ -166,7 +168,12 @@ public class AboutActivity extends CatimaAppCompatActivity implements View.OnCli
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse(url));
startActivity(intent);
try {
startActivity(intent);
} catch (ActivityNotFoundException e) {
Toast.makeText(this, R.string.failedToOpenUrl, Toast.LENGTH_LONG).show();
Log.e(TAG, "No activity found to handle intent", e);
}
}
}

View File

@@ -247,4 +247,5 @@
</plurals>
<string name="previousCard">Предишна</string>
<string name="nextCard">Следваща</string>
<string name="failedToOpenUrl">Първо инсталирайте уеб браузър</string>
</resources>

View File

@@ -292,4 +292,5 @@
</plurals>
<string name="previousCard">Previous</string>
<string name="nextCard">Next</string>
<string name="failedToOpenUrl">Install a web browser first</string>
</resources>