Skip to content

Instantly share code, notes, and snippets.

@musoftware
Created November 19, 2021 21:56
Show Gist options
  • Save musoftware/43602d70465da10e75bde6b48c67d5b7 to your computer and use it in GitHub Desktop.
Save musoftware/43602d70465da10e75bde6b48c67d5b7 to your computer and use it in GitHub Desktop.
Social Android Studio
public static Intent getOpenFacebookIntent(Context context) {
try {
context.getPackageManager().getPackageInfo("com.facebook.katana", 0);
Intent intent = new Intent("android.intent.action.VIEW", Uri.parse("fb://page/xxx"));
intent.addFlags(CrashUtils.ErrorDialogData.BINDER_CRASH);
return intent;
} catch (Exception unused) {
return new Intent("android.intent.action.VIEW", Uri.parse("https://www.facebook.com/xxx/"));
}
}
public static Intent getOpenTwitterIntent(Context context) {
try {
context.getPackageManager().getPackageInfo("com.twitter.android", 0);
Intent intent = new Intent("android.intent.action.VIEW", Uri.parse("twitter://user?user_id=USERID"));
intent.addFlags(CrashUtils.ErrorDialogData.BINDER_CRASH);
return intent;
} catch (Exception unused) {
return new Intent("android.intent.action.VIEW", Uri.parse("https://twitter.com/PROFILENAME"));
}
}
public static Intent getOpenInstagramIntent(Context context) {
try {
context.getPackageManager().getPackageInfo("com.instagram.android", 0);
Intent intent = new Intent("android.intent.action.VIEW", Uri.parse("http://instagram.com/_u/xxx"));
intent.addFlags(CrashUtils.ErrorDialogData.BINDER_CRASH);
intent.setPackage("com.instagram.android");
return intent;
} catch (Exception unused) {
return new Intent("android.intent.action.VIEW", Uri.parse("http://instagram.com/xxx"));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment