【问题标题】:How to detect app android or iOS installed in any browser mobile?如何检测安装在任何浏览器手机中的应用程序 android 或 iOS?
【发布时间】:2014-07-24 04:40:37
【问题描述】:

如何检测安装在任何浏览器手机中的应用程序 android 或 iOS ???

示例:当我转到地址 http://news.zing.vn 时,如果未安装应用程序,则会显示一条警报,并显示类似“应用程序 xxx 已在商店中可用。立即安装”的消息。

如果选择确定,手机将使用我的应用打开 Play Store(Android) 或 AppStore(iOS)。 如果选择取消,浏览器会保存cookie,下次不再提示。

对不起我的英语不好!!!

【问题讨论】:

  • 我不认为该网站正在检查是否安装了该应用程序,这只是假设如果您使用的是移动网络应用程序,那么您可能没有安装本机应用程序
  • 我不确定是否检测是否已安装,但一般来说,Web 应用程序可以检测“用户代理”以确定它在哪个平台上运行。例如,如果你使用 jQuery,你可以调用这个 API api.jquery.com/jquery.browser
  • 谢谢大家!!!我认为现在无法检查已安装的应用程序 :) 可能需要等待 Google 或 Apple 支持 API。

标签: javascript android ios browser


【解决方案1】:

看看有没有帮助

if(CheckNetwork.isInternetAvailable(getActivity())) //returns true if internet available
            {
                boolean chrome_status  =   appInstallationStatus("com.android.chrome");  
                if(chrome_status) {
                    //This intent will help you to launch if the package is already installed
                    Log.i("App already installed on your phone");
                    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
                    builder.setTitle("Info");
                    builder.setMessage("Google Chrome is the preferred browser. For best performance please select Chrome")
                   .setCancelable(false)
                   .setPositiveButton("OK", new DialogInterface.OnClickListener() {
                       public void onClick(DialogInterface dialog, int id) {
                           dialog.cancel();

Intent intent = new Intent(getActivity(), MyActivity.class);
startActivity(intent);
                       }
                   });
                    builder.create();
                    builder.show();
                }
                else {
                     Log.i("App is not installed on your phone");
                     AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
                     builder.setTitle("Info")
                     .setMessage("No Google Chrome found. Chrome is the preferred browser. Do you want to install it ?")
                     .setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
                         public void onClick(DialogInterface dialog, int which) { 
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://play.google.com/store/apps/details?id="+"com.android.chrome&hl=en")));
                         }
                      })
                     .setNegativeButton(android.R.string.no, new DialogInterface.OnClickListener() {
                         public void onClick(DialogInterface dialog, int which) { 

dialog.cancel();
Intent intent = new Intent(getActivity(), MyActivity.class);
startActivity(intent);
                         }
                      })
                     .setIcon(android.R.drawable.ic_dialog_alert)
                      .show();
                }
            }   
            else {
                AlertDialog.Builder alertDialog = new AlertDialog.Builder(getActivity());
                alertDialog.setTitle("Network Error");
                alertDialog.setMessage("No network connectivity. Please try again later!");
                alertDialog.setPositiveButton(R.string.cancel,
                        new DialogInterface.OnClickListener() {
                            public void onClick(DialogInterface dialog, int id) {

                            }
                });
                alertDialog.create().show();
            }

其他尝试查看此链接。 Detect from browser if a specific application is installed in Android

【讨论】:

    【解决方案2】:

    我认为网站不可能知道该应用程序是否安装在移动设备上。

    您几乎可以做的就是判断用户使用的是 Android 还是 iOS 系统。然后根据用户使用的系统向他们显示指向 iTunes App Store 或 Google Play Store 的链接。如果他们点击取消,则保存一个 cookie,下次不再显示警报。

    【讨论】:

      猜你喜欢
      • 2012-07-20
      • 2018-12-28
      • 2022-01-03
      • 2019-08-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多