Android calls the system to share the shared content to other applications, and does not use the pop-up window of the system's ActionBar, which is completely customized. androidactionbar
When Android shares content to other apps, the pop-up window of the calling system's Dialog or ActionBar is not very free and the limit is too large. Here I provide a fully customized interface that can pop up the window, you can also customize the interface directly in Activity or Fragment. Here I show a key class code, do the encapsulation processing, I write two Demo, free source code in: http://download.csdn.net/detail/yanzhenjie1003/8565449
/*** @ Author YOLANDA * @ Time 1:03:11 on October 11 */public class ShareUtil {/*** get the application data to be displayed * @ author YOLANDA * @ param context * @ param type * @ return */public static ArrayList <ListDrawableItem> getShowData (Context context, list <ResolveInfo> resolveInfos) {ArrayList <ListDrawableItem> drawableItems = new ArrayList <ListDrawableItem> (); PackageManager mPackageManager = context. getPackageManager (); for (int I = 0; I <resolveInfos. size (); I ++) {ResolveInfo info = resolveInfos. get (I); ListDrawableItem dialogItemEntity = new ListDrawableItem (info. loadLabel (mPackageManager), info. loadIcon (mPackageManager); drawableItems. add (dialogItemEntity);} return drawableItems ;} /*** share the content via the system * @ author YOLANDA * @ param context * @ param ChooserTitle selector title * @ param packageName package name * @ param imgPathOrText image path or text *@ param type: type of the shared content */public static void exeShare (Context context, string chooserTitle, String packageName, String imgPathOrText, Type type) {Intent intent = new Intent (Intent. ACTION_SEND); switch (type) {case Image: intent. setType ("image/*"); File imgPath = new File (imgPathOrText); Uri uri = Uri. fromFile (imgPath); intent. putExtra (Intent. EXTRA_STREAM, uri); break; case Text: intent. setType ("text/plain"); intent. putExtra (Intent. EXTRA_TEXT, imgPathOrText); break;} intent. setPackage (packageName); intent. setFlags (Intent. FLAG_ACTIVITY_NEW_TASK); try {context. startActivity (Intent. createChooser (intent, chooserTitle);} catch (ActivityNotFoundException e) {}}/*** get the application that supports sharing * @ author YOLANDA * @ param context * @ return */public static List <ResolveInfo> getShareTargets (Context context, Type type) {List <ResolveInfo> mApps = new ArrayList <ResolveInfo> (); Intent intent = new Intent (Intent. ACTION_SEND, null); intent. addCategory (Intent. CATEGORY_DEFAULT); switch (type) {case Image: intent. setType ("image/*"); break; default: intent. setType ("text/plain"); break;} PackageManager pm = context. getPackageManager (); mApps = pm. queryIntentActivities (intent, PackageManager. COMPONENT_ENABLED_STATE_DEFAULT); return mApps;}/*** sharing type * @ Project SmartControl * @ Class ShareUtil. java * @ author YOLANDA * @ Time March 4, 2015 10:21:16 */public enum Type {/** Image **/Image,/** Text **/Text ;}}