Skip to content

Instantly share code, notes, and snippets.

@drewlarsen
Last active April 26, 2019 18:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save drewlarsen/1c55254464168ed1efb6a528232087e5 to your computer and use it in GitHub Desktop.
Save drewlarsen/1c55254464168ed1efb6a528232087e5 to your computer and use it in GitHub Desktop.
How to Open SugarWOD from another Android App
// Adapted from:
// https://stackoverflow.com/questions/2780102/open-another-application-from-your-own-intent/7596063#7596063
/** Open SugarWOD.
* @param context current Context, like Activity, App, or Service
* @return true if likely successful, false if unsuccessful
*/
public static boolean openSugarWOD(Context context) {
String packageName = "com.flatironssoftware.sugarwod";
PackageManager manager = context.getPackageManager();
try {
Intent i = manager.getLaunchIntentForPackage(packageName);
if (i == null) {
return false;
}
i.addCategory(Intent.CATEGORY_LAUNCHER);
context.startActivity(i);
return true;
} catch (ActivityNotFoundException e) {
return false;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment