android调用系统分享指定某些应用
2018-02-12 12:12
387 查看
有个需求是在调用系统分享的时候,分享到页面地图打不开,所以分享列表中药去掉地图类的应用,具体实现如下,需要注意的是当同一个应用内有多个响应的组件,intent直接设置setPackageName()会导致出现系统的图标,点击后里面是一个应用的俩种分享途径,例如注释所述,所以需要制定包名和类名,给系统具体的信息
没有使用 Intent intent = new Intent( Intent.createChooser(intent,title))如下
使用createChooser
private Intent dealResultWithoutMapIntent(Boolean isLongClick) { StringBuilder sb = null; if (!isLongClick) { sb = new StringBuilder(mShareManager.getShareDisplayContent()); sb.append(mShareMessage.getContentUrl()); } other.setType("text/plain"); List<ResolveInfo> resolveInfos = mContext.getPackageManager().queryIntentActivities(other, 0); List<Intent> targetIntents = new ArrayList<>(); for (ResolveInfo info : resolveInfos) { Intent target = new Intent(Intent.ACTION_SEND); target.setType("text/plain"); if (!info.activityInfo.packageName.toLowerCase().contains("map")){ /** * 应该指定具体的包名,类名,否则相同app的不同分享方式会放在一个分组里, * eg.wechat的俩种分享响应类 * com.tencent.mm.ui.tools.ShareImgUI * com.tencent.mm.ui.tools.AddFavoriteUI * 会显示系统图标,点击进去是一个app的俩种分享途径 */ target.setClassName(info.activityInfo.packageName,info.activityInfo.name); target.putExtra(Intent.EXTRA_TEXT,isLongClick ? mShareManager.getShareDisplayContent() : sb.toString()); target.putExtra(Intent.EXTRA_SUBJECT,mShareMessage.getTitle()); targetIntents.add(target); } } // 应该去掉第一个chooserIntent , 否则会重复 Intent chooserIntent = Intent.createChooser(targetIntents.remove(0),mContext.getResources().getText(R.string.system_share_title)); chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS,targetIntents.toArray(new Parcelable[]{})); return chooserIntent; } }
没有使用 Intent intent = new Intent( Intent.createChooser(intent,title))如下
使用createChooser
相关文章推荐
- Android调用系统分享,指定某些应用来分享
- Android学习笔记 —— Android开发中,不调用系统浏览器直接在应用中显示指定网址的内容
- Android 调用系统分享(不使用第三方),指定QQ、微信等
- Android调用系统分享和指定app分享-微信朋友圈图文分享和qq分享
- Android调用系统分享和指定app分享-微信朋友圈图文分享和qq分享
- android 调用系统应用
- 【android中级】Android 系统应用调用,intent的使用总结
- android 关于将应用添加到系统的 分享.. 或者 发送到.. 中
- Android 系统应用调用,intent 的使用总结
- 自己的应用中调用android系统闹钟
- android调用系统应用
- Android 系统应用调用,intent的使用总结
- Android应用开发之调用系统Activity发送短信
- 使用intent调用Android系统自带应用
- Android使用系统Intent实现分享功能及将应用加入分享列表++分享邮箱实现
- Android调用系统分享功能以及createChooser的使用
- android调用系统应用
- 【Android】调用系统应用常用uri & intent设置
- Android 调用系统应用
- Android 系统应用调用,intent的使用总结帖