0

How to detect app android or iOS installed in any browser mobile ???

Example : When I go to address http://news.zing.vn , if app didn't install,one alert will show with message like this "App xxx is avaiable in Store. Install now."

If choose OK, phone will open Play Store(Android) or AppStore(iOS) with my app. If choose Cancel, browser will save cookie and don't show alert in next time.

Sorry for my bad English !!!

DucPT
  • 41
  • 1
  • 6
  • I don't think the website is checking to see if the app is installed, it is just assuming that if you are using the mobile web app then you probably don't have a native app installed – panini Jul 24 '14 at 04:44
  • I'm not sure about detecting if installed or not, but in general terms a web app can detect the 'User Agent' to determine what platform it's running on. For example, if you are using jQuery, you can call this API http://api.jquery.com/jquery.browser/ – Nebu Jul 24 '14 at 05:07
  • Thanks all of you !!! I think is not possible to check app installed at now :) May be wait to Google or Apple support API. – DucPT Jul 24 '14 at 06:59

2 Answers2

1

See if it helps

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();
            }

Else try to see this link. Detect from browser if a specific application is installed in Android

Community
  • 1
  • 1
StackUser
  • 141
  • 1
  • 1
  • 8
0

I don't believe it's possible for the website to know if the app is installed on the mobile device or not.

Pretty much what you can do is tell if the user is using an Android or iOS system. Then show them a link to either the iTunes App Store or the Google Play Store depending on which system the user is using. If they click on Cancel then save a cookie and don't show the alert next time.

compman2408
  • 2,369
  • 1
  • 15
  • 15