Android跳转到应用商店详情页面
2017-11-27 14:55
567 查看
最近有一个需求,产品经理按照IOS发布新版后在appstore评论或者评分功能设计的,让Android跳转到本机应用商店中本应用的详情页。
上网查了一些资料,实现步骤如下:
弹出对话框:
MyDialog为对话框样式:
点击对话框按钮获取跳转意图:
判断是否有应用商店:
跳转到应用详情:
最终实现结果:
评论和评分,在Android上只能进入详情页,由用户点击评价进到评分和评论的页面,所以跳转逻辑一样;
进行跳转只能跳转到本机已安装应用,所以进入的是本机预装的应用商店。如果本机应用商店中没有收录自己的应用,跳转后搜索不到应用包名。ps:然而上线前这个功能被pass掉了。
上网查了一些资料,实现步骤如下:
弹出对话框:
/** * 应用评价对话框 * * @param activity 上下文 * @return 对话框 */ public static Dialog showAppSuggestDialog(Activity activity) { Dialog dialog = new Dialog(activity, R.style.MyDialog); View contentView = View.inflate(activity, R.layout.dialog_version_suggest, null); dialog.setContentView(contentView); dialog.setCanceledOnTouchOutside(true); dialog.show(); ImageView update_close = contentView.findViewById(R.id.update_close); TextView tv_say_bad = contentView.findViewById(R.id.tv_say_bad); TextView tv_say_good = contentView.findViewById(R.id.tv_say_good); update_close.setOnClickListener(view -> dialog.dismiss()); tv_say_bad.setOnClickListener(view -> { dialog.dismiss(); toMarket(activity); }); tv_say_good.setOnClickListener(view -> { dialog.dismiss(); toMarket(activity); }); return dialog; }
MyDialog为对话框样式:
<style name="MyDialog" parent="@android:style/Theme.Dialog"> <item name="android:windowFrame">@null</item> <item name="android:windowBackground">@android:color/transparent</item> <item name="android:windowNoTitle">true</item> <item name="android:background">@color/transparent</item> </style>
点击对话框按钮获取跳转意图:
/** * 获取跳转意图 * * @param context 上下文 * @return 意图 */ public static Intent getIntent(Context context) { StringBuilder localStringBuilder = new StringBuilder().append("market://details?id="); String str = context.getPackageName(); localStringBuilder.append(str); Uri localUri = Uri.parse(localStringBuilder.toString()); return new Intent("android.intent.action.VIEW", localUri); }
判断是否有应用商店:
/** * 判断是否有应用市场 * * @param context 上下文 * @param marketIntent 跳转意图 * @return 是否有应用市场true/false */ public static boolean judge(Context context, Intent marketIntent) { List<ResolveInfo> localList = context.getPackageManager().queryIntentActivities(marketIntent, PackageManager.GET_RESOLVED_FILTER); if ((localList != null) && (localList.size() > 0)) { return false; } else { return true; } }
跳转到应用详情:
/** * 跳转到应用详情页 * * @param activity 上下文 */ private static void toMarket(Activity activity) { Intent intent = getIntent(activity); boolean b = judge(activity, intent); if (!b) { try { activity.startActivity(intent); } catch (ActivityNotFoundException e) { MyToast.showToast(Constants.ERROR_NO_MARKET); } } else { MyToast.showToast(Constants.ERROR_NO_MARKET); } }
最终实现结果:
评论和评分,在Android上只能进入详情页,由用户点击评价进到评分和评论的页面,所以跳转逻辑一样;
进行跳转只能跳转到本机已安装应用,所以进入的是本机预装的应用商店。如果本机应用商店中没有收录自己的应用,跳转后搜索不到应用包名。ps:然而上线前这个功能被pass掉了。
相关文章推荐
- Android如何跳转到应用商店的APP详情页面
- Android如何跳转到应用商店的APP详情页面
- Android跳转到应用商店的APP详情页面,以及 Google GMS 各个apk的包
- Android跳转到应用商店的APP详情页面
- Android跳转到应用商店的APP详情页面,以及 Google GMS 各个apk的包
- Android应用如何跳转到应用市场详情页面
- Android适配 - 跳转应用商店查看应用详情
- android:检查系统是否开启消息通知权限,app应用点击开启通知时跳转到app详情页面开启权限
- Android跳转谷歌商店APP详情页面
- Android应用自动跳转到应用市场详情页面的方法
- 【转】Android应用如何跳转到应用市场详情页面
- android 跳转到当前应用的详情页面
- "给我评分" 模块,跳转到相应的应用商店--apk展示详情页面
- android 跳转到当前应用的详情页面
- Android应用如何跳转到应用市场详情页面
- Android应用如何跳转到应用市场详情页面
- Android深入浅出系列之实例应用—手机页面之间的跳转
- Android 跳转到一个应用安装的详情界面的方法
- Android 跨应用跳转页面
- android如何从一个应用跳转到另一个页面