Skip to content

Instantly share code, notes, and snippets.

@drewlarsen drewlarsen/sugarwod.java
Last active Apr 26, 2019

Embed
What would you like to do?
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
You can’t perform that action at this time.