Checking the google plus availability

87 views Asked by At

In Android,I am using the Google plus interactive post and G+1 button. Before I start the Interactive Posting, I need to make sure if the google Plus app is available in the device. For now, I am using the bellow try catch method to catch the failure. Could you please advice a better way to check the availability of the google plus app availability in the device.

    try {
        startActivityForResult(getInteractivePostIntent(msg), REQUEST_CODE_INTERACTIVE_POST);
    } catch (ActivityNotFoundException e) {
        toastSimple("You haven't installed google+ on your device");
    }
1

There are 1 answers

3
bjiang On

From the official doc here:

https://developers.google.com/+/mobile/android/getting-started#frequently_asked_questions

The GooglePlusUtil#checkGooglePlusApp utility method returns GooglePlusUtil.SUCCESS if the Google+ app is installed. If the app is not installed, you can prompt the user to install the app with the GooglePlusUtil#getErrorDialog utility method.

int errorCode = GooglePlusUtil.checkGooglePlusApp(this);
if (errorCode != GooglePlusUtil.SUCCESS) {
  GooglePlusUtil.getErrorDialog(errorCode, this, 0).show();
}