public List<AppInfoVo> getShareApps(Context context) {
PackageManager packageManager = context.getPackageManager();
List<AppInfoVo> appInfoVos = new ArrayList<AppInfoVo>();
List<ResolveInfo> resolveInfos = new ArrayList<ResolveInfo>();
Intent intent = new Intent(Intent.ACTION_SEND, null);
intent.addCategory(Intent.CATEGORY_DEFAULT);
intent.setType("*/*");
PackageManager pManager = context.getPackageManager();
resolveInfos = pManager.queryIntentActivities(intent, PackageManager
.COMPONENT_ENABLED_STATE_DEFAULT);
for (int i = 0; i < resolveInfos.size(); i++) {
AppInfoVo appInfoVo = new AppInfoVo();
ResolveInfo resolveInfo = resolveInfos.get(i);
appInfoVo.setAppName(resolveInfo.loadLabel(packageManager).toString());
appInfoVo.setIcon(resolveInfo.loadIcon(packageManager));
appInfoVo.setPackageName(resolveInfo.activityInfo.packageName);
appInfoVo.setLauncherName(resolveInfo.activityInfo.name);
appInfoVos.add(appInfoVo);
}
return appInfoVos;
}
Copy the code
public class AppInfoVo { private Drawable icon; private String appName; private String packageName; private boolean isSystemApp; private long codesize; private String launcherName; public String getLauncherName() { return launcherName; } public void setLauncherName(String launcherName) { this.launcherName = launcherName; } public long getCodesize() { return codesize; } public void setCodesize(long codesize) { this.codesize = codesize; } public Drawable getIcon() { return icon; } public void setIcon(Drawable icon) { this.icon = icon; } public String getAppName() { return appName; } public void setAppName(String appName) { this.appName = appName; } public String getPackageName() { return packageName; } public void setPackageName(String packageName) { this.packageName = packageName; } public boolean isSystemApp() { return isSystemApp; } public void setSystemApp(boolean isSystemApp) { this.isSystemApp = isSystemApp; }}Copy the code
Debug the appInfoVos
For example, check the Activity and package name of the video published in QQ Space
Common application package name
WeChat friends “com. Tencent. Mm” “com. Tencent. Mm. UI. View ShareToTimeLineUI”
WeChat friends “com. Tencent. Mm” “com. Tencent. Mm. UI. View ShareImgUI”
QQ friends “com. Tencent. Mobileqq” “com. Tencent. Mobileqq. Activity. JumpActivity”
QQ space to share video “com. Qzone” and “com. Qzonex. Module. Maxvideo. Activity. QzonePublishVideoActivity”
QQ space to share pictures, text “com. Qzone” “. Com. Qzonex. The module operation. UI. QZonePublishMoodActivity”
Sina weibo “com, sina weibo” “com.sina.weibo.composerinde.Com poserDispatchActivity”