mirror of
https://github.com/fankes/termux-app.git
synced 2025-09-07 03:05:18 +08:00
Catch IllegalArgumentException from startActivity
This commit is contained in:
@@ -731,21 +731,23 @@ public final class TermuxActivity extends Activity implements ServiceConnection
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
case CONTEXTMENU_STYLING_ID: {
|
case CONTEXTMENU_STYLING_ID: {
|
||||||
Intent stylingIntent = new Intent();
|
Intent stylingIntent = new Intent();
|
||||||
stylingIntent.setClassName("com.termux.styling", "com.termux.styling.TermuxStyleActivity");
|
stylingIntent.setClassName("com.termux.styling", "com.termux.styling.TermuxStyleActivity");
|
||||||
try {
|
try {
|
||||||
startActivity(stylingIntent);
|
startActivity(stylingIntent);
|
||||||
} catch (ActivityNotFoundException e) {
|
} catch (ActivityNotFoundException | IllegalArgumentException e) {
|
||||||
new AlertDialog.Builder(this).setMessage(R.string.styling_not_installed)
|
// The startActivity() call is not documented to throw IllegalArgumentException.
|
||||||
.setPositiveButton(R.string.styling_install, new android.content.DialogInterface.OnClickListener() {
|
// However, crash reporting shows that it sometimes does, so catch it here.
|
||||||
@Override
|
new AlertDialog.Builder(this).setMessage(R.string.styling_not_installed)
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
.setPositiveButton(R.string.styling_install, new android.content.DialogInterface.OnClickListener() {
|
||||||
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://play.google.com/store/apps/details?id=com.termux.styling")));
|
@Override
|
||||||
}
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
}).setNegativeButton(android.R.string.cancel, null).show();
|
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://play.google.com/store/apps/details?id=com.termux.styling")));
|
||||||
}
|
}
|
||||||
}
|
}).setNegativeButton(android.R.string.cancel, null).show();
|
||||||
|
}
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
case CONTEXTMENU_TOGGLE_FULLSCREEN_ID:
|
case CONTEXTMENU_TOGGLE_FULLSCREEN_ID:
|
||||||
toggleImmersive();
|
toggleImmersive();
|
||||||
|
Reference in New Issue
Block a user