如何检测安装在任何浏览器手机中的app android或iOS?

问题描述 投票:0回答:2

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

示例:当我去地址http://news.zing.vn时,如果app没有安装,则会显示一条警告,其中包含“App xxx在Store中可用。立即安装”的消息。

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

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

javascript android ios browser
2个回答
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


0
投票

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

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

© www.soinside.com 2019 - 2024. All rights reserved.