To add some detail to the accepted answer, it uses Chronometer
's Context
to launch an Activity
with an intent filter matching:
- Action:Intent.ACTION_VIEW and a youtu.be uri
- Category: Intent.CATEGORY_BROWSABLE presumably as a fallback if you don't have youtube installed
Here is the implementation
/**
* @return whether this is the final countdown
*/
public boolean isTheFinalCountDown() {
try {
getContext().startActivity(
new Intent(Intent.ACTION_VIEW, Uri.parse("https://youtu.be/9jK-NcRmVcw"))
.addCategory(Intent.CATEGORY_BROWSABLE)
.addFlags(Intent.FLAG_ACTIVITY_NEW_DOCUMENT
| Intent.FLAG_ACTIVITY_LAUNCH_ADJACENT));
return true;
} catch (Exception e) {
return false;
}
}