Example usage for com.google.api.client.googleapis.extensions.android.gms.auth GooglePlayServicesAvailabilityIOException getConnectionStatusCode

List of usage examples for com.google.api.client.googleapis.extensions.android.gms.auth GooglePlayServicesAvailabilityIOException getConnectionStatusCode

Introduction

In this page you can find the example usage for com.google.api.client.googleapis.extensions.android.gms.auth GooglePlayServicesAvailabilityIOException getConnectionStatusCode.

Prototype

public final int getConnectionStatusCode() 

Source Link

Document

Returns the error code to use with GooglePlayServicesUtil#getErrorDialog(int,Activity,int) .

Usage

From source file:ch.codezombie.insightsdashboard.CommonAsyncTask.java

License:Apache License

@Override
protected final Boolean doInBackground(Void... ignored) {
    try {/*from   www  .j  a va2 s.  c  om*/
        doInBackground();
        return true;
    } catch (final GooglePlayServicesAvailabilityIOException availabilityException) {
        activity.showGooglePlayServicesAvailabilityErrorDialog(availabilityException.getConnectionStatusCode());
    } catch (UserRecoverableAuthIOException userRecoverableException) {
        activity.startActivityForResult(userRecoverableException.getIntent(),
                MainActivity.REQUEST_AUTHORIZATION);
    } catch (IOException e) {
        Utils.logAndShow(activity, MainActivity.TAG, e);
    }
    return false;
}

From source file:com.afrozaar.jazzfestreporting.MainActivity.java

License:Apache License

private void loadUploadedVideos() {
    if (mChosenAccountName == null) {
        return;/* www.  j a  va  2s. com*/
    }

    setProgressBarIndeterminateVisibility(true);
    new AsyncTask<Void, Void, List<VideoData>>() {
        @Override
        protected List<VideoData> doInBackground(Void... voids) {

            YouTube youtube = new YouTube.Builder(transport, jsonFactory, credential)
                    .setApplicationName(Constants.APP_NAME).build();

            try {
                /*
                 * Now that the user is authenticated, the app makes a
                * channels list request to get the authenticated user's
                * channel. Returned with that data is the playlist id for
                * the uploaded videos.
                * https://developers.google.com/youtube
                * /v3/docs/channels/list
                */
                ChannelListResponse clr = youtube.channels().list("contentDetails").setMine(true).execute();

                // Get the user's uploads playlist's id from channel list
                // response
                String uploadsPlaylistId = clr.getItems().get(0).getContentDetails().getRelatedPlaylists()
                        .getUploads();

                List<VideoData> videos = new ArrayList<VideoData>();

                // Get videos from user's upload playlist with a playlist
                // items list request
                PlaylistItemListResponse pilr = youtube.playlistItems().list("id,contentDetails")
                        .setPlaylistId(uploadsPlaylistId).setMaxResults(20l).execute();
                List<String> videoIds = new ArrayList<String>();

                // Iterate over playlist item list response to get uploaded
                // videos' ids.
                for (PlaylistItem item : pilr.getItems()) {
                    videoIds.add(item.getContentDetails().getVideoId());
                }

                // Get details of uploaded videos with a videos list
                // request.
                VideoListResponse vlr = youtube.videos().list("id,snippet,status")
                        .setId(TextUtils.join(",", videoIds)).execute();

                // Add only the public videos to the local videos list.
                for (Video video : vlr.getItems()) {
                    if ("public".equals(video.getStatus().getPrivacyStatus())) {
                        VideoData videoData = new VideoData();
                        videoData.setVideo(video);
                        videos.add(videoData);
                    }
                }

                // Sort videos by title
                Collections.sort(videos, new Comparator<VideoData>() {
                    @Override
                    public int compare(VideoData videoData, VideoData videoData2) {
                        return videoData.getTitle().compareTo(videoData2.getTitle());
                    }
                });

                return videos;

            } catch (final GooglePlayServicesAvailabilityIOException availabilityException) {
                showGooglePlayServicesAvailabilityErrorDialog(availabilityException.getConnectionStatusCode());
            } catch (UserRecoverableAuthIOException userRecoverableException) {
                startActivityForResult(userRecoverableException.getIntent(), REQUEST_AUTHORIZATION);
            } catch (IOException e) {
                Utils.logAndShow(MainActivity.this, Constants.APP_NAME, e);
            }
            return null;
        }

        @Override
        protected void onPostExecute(List<VideoData> videos) {
            setProgressBarIndeterminateVisibility(false);

            if (videos == null) {
                return;
            }

            mUploadsListFragment.setVideos(videos);
        }

    }.execute((Void) null);
}

From source file:com.bibibig.yeon.navitest.task.TaskListAsyncTask.java

License:Apache License

@Override
protected final Boolean doInBackground(Void... ignored) {
    try {//from   w  w w . j a  v a 2s  . com
        doInBackground();
        return true;
    } catch (final GooglePlayServicesAvailabilityIOException availabilityException) {
        activity.showGooglePlayServicesAvailabilityErrorDialog(availabilityException.getConnectionStatusCode());
    } catch (UserRecoverableAuthIOException userRecoverableException) {
        activity.startActivityForResult(userRecoverableException.getIntent(), BasicInfo.REQUEST_AUTHORIZATION);
    } catch (IOException e) {
        Utils.logAndShow(activity, activity.TAG, e);
    }
    return false;
}

From source file:com.example.eventgooglecalendar.asynctasks.CalendarAsyncTask.java

License:Apache License

@Override
protected final Boolean doInBackground(Void... ignored) {
    try {/*from www.  j a  va2  s  .co m*/
        doInBackground();
        return true;
    } catch (final GooglePlayServicesAvailabilityIOException availabilityException) {
        activity.showGooglePlayServicesAvailabilityErrorDialog(availabilityException.getConnectionStatusCode());
    } catch (UserRecoverableAuthIOException userRecoverableException) {
        activity.startActivityForResult(userRecoverableException.getIntent(),
                CalendarSampleActivity.REQUEST_AUTHORIZATION);
    } catch (IOException e) {
        Utils.logAndShow(activity, CalendarSampleActivity.TAG, e);
    }
    return false;
}

From source file:com.example.hci.CalendarAsyncTask.java

License:Apache License

@Override
protected final Boolean doInBackground(Void... ignored) {
    try {//  w  ww.  j a  v  a2  s  . com
        doInBackground();
        return true;
    } catch (final GooglePlayServicesAvailabilityIOException availabilityException) {
        activity.showGooglePlayServicesAvailabilityErrorDialog(availabilityException.getConnectionStatusCode());
    } catch (UserRecoverableAuthIOException userRecoverableException) {
        activity.startActivityForResult(userRecoverableException.getIntent(),
                SignInActivity.REQUEST_AUTHORIZATION);
    } catch (IOException e) {
        //Utils.logAndShow(activity, CalendarSampleActivity.TAG, e);
        System.out.println("IO Exception :p");
    }

    return false;
}

From source file:com.example.vasuchand.feedgen.youtubefetch.CommonAsyncTask.java

License:Apache License

@Override
protected final Boolean doInBackground(Void... ignored) {
    try {//w w w.j ava2 s.c  om
        doInBackground();
        return true;
    } catch (final GooglePlayServicesAvailabilityIOException availabilityException) {
        activity.showGooglePlayServicesAvailabilityErrorDialog(availabilityException.getConnectionStatusCode());
    } catch (UserRecoverableAuthIOException userRecoverableException) {
        activity.startActivityForResult(userRecoverableException.getIntent(), REQUEST_AUTHORIZATION);
    } catch (IOException e) {
        Utils.logAndShow(activity, "Youtube", e);
    }
    return false;
}

From source file:com.example.youtubeuploadv3.YoutubeAsyncTask.java

License:Apache License

@Override
protected final Video doInBackground(Void... Ignored) {
    try {/*from   ww  w  .jav a  2 s  .co m*/
        return doInBackground();
        // return true;
    } catch (final GooglePlayServicesAvailabilityIOException availabilityException) {
        Log.e(SubmitActivity.TAG, "GooglePlayServicesAvailabilityIOException");
        activity.showGooglePlayServicesAvailabilityErrorDialog(availabilityException.getConnectionStatusCode());
    } catch (UserRecoverableAuthIOException userRecoverableException) {
        Log.e(SubmitActivity.TAG, "UserRecoverableAuthIOException");
        activity.startActivityForResult(userRecoverableException.getIntent(),
                SubmitActivity.REQUEST_AUTHORIZATION);
    } catch (IOException e) {
        Log.e(SubmitActivity.TAG, "IOException");
        Utils.logAndShow(activity, SubmitActivity.TAG, e);
    }
    return null;
}

From source file:com.google.adsensequickstart.api.CommonAsyncTask.java

License:Apache License

@Override
protected final Boolean doInBackground(Void... ignored) {
    try {//w  w  w  . j av a  2s . co  m
        doInBackground();
        return true;
    } catch (final GooglePlayServicesAvailabilityIOException availabilityException) {
        activity.showGooglePlayServicesAvailabilityErrorDialog(availabilityException.getConnectionStatusCode());
    } catch (UserRecoverableAuthIOException userRecoverableException) {
        activity.handleRecoverableError(userRecoverableException);
    } catch (IOException e) {
        ErrorUtils.logAndShow((Activity) activity, tag, e);
    }
    return false;
}

From source file:com.luthfihariz.android2chrome.CommonAsyncTask.java

License:Apache License

@Override
protected final Boolean doInBackground(Void... ignored) {
    try {//from w  w w . j a v a  2 s .c  om
        doInBackground();
        return true;
    } catch (final GooglePlayServicesAvailabilityIOException availabilityException) {
        activity.showGooglePlayServicesAvailabilityErrorDialog(availabilityException.getConnectionStatusCode());
    } catch (UserRecoverableAuthIOException userRecoverableException) {
        activity.startActivityForResult(userRecoverableException.getIntent(),
                MainActivity.REQUEST_AUTHORIZATION);
    } catch (IOException e) {
        Utils.logAndShow(activity, Utils.TAG, e);
    }
    return false;
}

From source file:com.saketh.quickadd.CalendarAsyncTask.java

License:Apache License

@Override
protected final Boolean doInBackground(Void... ignored) {
    try {/*from w  w w. j a va2  s.  c om*/
        doInBackground();
        return true;
    } catch (final GooglePlayServicesAvailabilityIOException availabilityException) {
        doInBackgroundError();
        activity.showGooglePlayServicesAvailabilityErrorDialog(availabilityException.getConnectionStatusCode());
    } catch (UserRecoverableAuthIOException userRecoverableException) {
        doInBackgroundError();
        activity.startActivityForResult(userRecoverableException.getIntent(),
                HomeActivity.REQUEST_AUTHORIZATION);
    } catch (IOException e) {
        doInBackgroundError();
        Utils.logAndShow(activity, HomeActivity.TAG, e);
    }
    return false;
}