fix(android): verify browser before starting activity

Fixes #6899.
This commit is contained in:
Marc Durdin 2022-07-27 15:16:02 +10:00
parent e9b0ea6558
commit bdb7b5e45a
6 changed files with 22 additions and 7 deletions

View file

@ -113,7 +113,9 @@ public class KMPBrowserActivity extends BaseActivity {
// All links that aren't internal Keyman keyboard links open in user's browser
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
startActivity(intent);
if (intent.resolveActivity(getPackageManager()) != null) {
startActivity(intent);
}
return true;
}
if (lowerURL.startsWith("keyman:")) {

View file

@ -160,7 +160,9 @@ public final class KeyboardSettingsActivity extends AppCompatActivity {
Bundle args = kbd.buildDownloadBundle();
Intent i = new Intent(getApplicationContext(), KMKeyboardDownloaderActivity.class);
i.putExtras(args);
startActivity(i);
if (i.resolveActivity(getPackageManager()) != null) {
startActivity(i);
}
finish();
// "Help" link clicked

View file

@ -762,10 +762,15 @@ public class MainActivity extends BaseActivity implements OnKeyboardEventListene
// Launch PlayStore to update Chrome
try {
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=com.android.chrome"));
startActivity(intent);
if (intent.resolveActivity(getPackageManager()) != null) {
startActivity(intent);
}
} catch (android.content.ActivityNotFoundException e) {
// Link to Chrome if user is not signed in to Play Store
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://play.google.com/store/apps/details?id=com.android.chrome")));
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://play.google.com/store/apps/details?id=com.android.chrome"));
if (intent.resolveActivity(getPackageManager()) != null) {
startActivity(intent);
}
}
}
});

View file

@ -136,7 +136,9 @@ public final class KeyboardInfoActivity extends BaseActivity {
} else {
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(customHelpLink));
startActivity(i);
if (i.resolveActivity(getPackageManager()) != null) {
startActivity(i);
}
}
}
}

View file

@ -252,7 +252,9 @@ final class FVShared {
String helpUrl = String.format("%s%s", FVKeyboardHelpLink, id);
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(helpUrl));
localContext.startActivity(i);
if (i.resolveActivity(getPackageManager()) != null) {
localContext.startActivity(i);
}
}
private void updateActiveKeyboardsList() {

View file

@ -105,7 +105,9 @@ public class MainActivity extends AppCompatActivity implements OnKeyboardDownloa
}
else {
Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
startActivity(i);
if (i.resolveActivity(getPackageManager()) != null) {
startActivity(i);
}
}
return true;