Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/224.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何检测安装在任何移动浏览器中的android或iOS应用程序?_Javascript_Android_Ios_Browser - Fatal编程技术网

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

Javascript 如何检测安装在任何移动浏览器中的android或iOS应用程序?,javascript,android,ios,browser,Javascript,Android,Ios,Browser,如何检测安装在任何手机浏览器中的android或iOS应用程序 示例:当我转到地址时,如果应用程序未安装,将显示一个警报,并显示如下消息:“应用程序xxx在商店中可用。立即安装。” 若选择OK,手机将使用我的应用程序打开Play Store(Android)或AppStore(iOS)。 若选择“取消”,浏览器将保存cookie并在下次不显示警报 对不起,我的英语不好 我认为网站不可能知道该应用是否安装在移动设备上 你所能做的就是判断用户是使用安卓系统还是iOS系统。然后根据用户使用的系统向他们

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

示例:当我转到地址时,如果应用程序未安装,将显示一个警报,并显示如下消息:“应用程序xxx在商店中可用。立即安装。”

若选择OK,手机将使用我的应用程序打开Play Store(Android)或AppStore(iOS)。 若选择“取消”,浏览器将保存cookie并在下次不显示警报


对不起,我的英语不好

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

你所能做的就是判断用户是使用安卓系统还是iOS系统。然后根据用户使用的系统向他们显示iTunes应用商店或Google Play商店的链接。如果他们单击“取消”,则保存一个cookie,下次不显示警报。

查看是否有帮助

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();
            }
否则请尝试查看此链接。

我不认为网站在检查应用程序是否已安装,它只是假设如果您正在使用移动web应用程序,那么您可能没有安装本机应用程序。我不确定是否已安装,但一般来说,web应用程序可以检测“用户代理”以确定其运行在哪个平台上。例如,如果您正在使用jQuery,您可以调用此API,谢谢大家!!!我认为目前无法检查安装的应用:)可能需要等待谷歌或苹果的API支持。