Intent share = new Intent(Intent.ACTION_SEND);
share.setType("text/plain");
share.putExtra(Intent.EXTRA_TEXT, shareText);
share.putExtra(Intent.EXTRA_SUBJECT, shareSubject);
if (uri != null) {
share.setType("image/*");
share.putExtra(Intent.EXTRA_STREAM, uri);
}
context.startActivity(Intent.createChooser(share, title));
private static List<List<ResolveInfo>> getShareActivities() {
Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND);
sharingIntent.setType("text/plain");
PackageManager pm = App.getInstance().getPackageManager();
List<List<ResolveInfo>> listArrayList = new ArrayList<>();
List<ResolveInfo> activityList = pm.queryIntentActivities(sharingIntent, 0);
List<ResolveInfo> newActivityList = new ArrayList<>();
for (Iterator<ResolveInfo> it = activityList.iterator(); it.hasNext(); ) {
ResolveInfo info = it.next();
//过滤出facebook google+ whatapp twitter 分享app单独处理
LogUtils.e("+++", info.activityInfo.packageName);
if (info.activityInfo.packageName.equals("com.android.bluetooth") || info.activityInfo.packageName.equals("com.android.nfc") || info.activityInfo.packageName.equals("com.facebook.katana") || info.activityInfo.packageName.equals("com.google.android.apps.plus") || info.activityInfo.packageName.equals("com.facebook.orca") || info.activityInfo.packageName.contains("whatsapp") || info.activityInfo.packageName.equals("com.twitter.android")) {
if (info.activityInfo.packageName.equals("com.android.bluetooth") || info.activityInfo.packageName.equals("com.android.nfc")) {
it.remove();
} else {
newActivityList.add(info);
it.remove();
}
}
}
//增加一条other数据
newActivityList.add(null);
listArrayList.add(newActivityList);
listArrayList.add(activityList);
return listArrayList;
}
public static void systemShareDialog(List<ResolveInfo> packages, Context context, String title, String shareText) {
List<Intent> targetIntents = new ArrayList<Intent>();
Intent shareIntent = new Intent(Intent.ACTION_SEND);
shareIntent.setType("text/plain");
SPM spm = new SPM();
for (ResolveInfo candidate : packages) {
String packageName = candidate.activityInfo.packageName;
Intent target = new Intent(android.content.Intent.ACTION_SEND);
target.setType("text/plain");
target.putExtra(Intent.EXTRA_TEXT, shareText);
//target.setPackage(packageName);
//t will be able to handle the case of multiple activities within the same app that can handle this intent. Otherwise, a weird item of "Android System" will be shown
target.setComponent(new ComponentName(packageName, candidate.activityInfo.name));
targetIntents.add(target);
}
// createchooser时使用targetIntents.remove(0)即传入targetIntents的第一个intent,并将其移除,
//
// 否则执行chooser.putExtra(Intent.EXTRA_INITIAL_INTENTS, targetIntents.toArray(new Parcelable[] {}));添加后启动时会出现两个相同的应用
Intent chooserIntent = Intent.createChooser(targetIntents.remove(0), title);
chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, targetIntents.toArray(new Parcelable[]{}));
context.startActivity(chooserIntent);
}
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有