private static void shareMethod ( String message , String activityInfoName ) { Intent shareIntent = new Intent ( Intent . ACTION_SEND ) ; shareIntent . setType ( "text/plain" ) ; shareIntent . putExtra ( Intent . EXTRA_TEXT , message ) ; PackageManager pm = QuickUtils . getContext ( ) . getPackageManager ( ) ; List < ResolveInfo > activityList = pm . queryIntentActivities ( shareIntent , 0 ) ; for ( final ResolveInfo app : activityList ) { if ( ( app . activityInfo . name ) . contains ( activityInfoName ) ) { final ActivityInfo activity = app . activityInfo ; final ComponentName name = new ComponentName ( activity . applicationInfo . packageName , activity . name ) ; shareIntent . addCategory ( Intent . CATEGORY_LAUNCHER ) ; shareIntent . setFlags ( Intent . FLAG_ACTIVITY_NEW_TASK | Intent . FLAG_ACTIVITY_RESET_TASK_IF_NEEDED ) ; shareIntent . setComponent ( name ) ; QuickUtils . getContext ( ) . startActivity ( shareIntent ) ; break ; } } }
Private method that handles facebook and twitter sharing