private void initChannel() { ChannelListResponse response = null; try { channelQuery = youtube.channels().list("id,snippet,brandingSettings,statistics"); channelQuery.setKey(this.KEY); channelQuery.setId(this.channel_id); channelQuery.setFields( "items(id,brandingSettings,snippet/title,snippet/description,snippet/thumbnails,statistics)"); } catch (IOException e) { Log.d("YC", "Could not init: " + e); } try { response = channelQuery.execute(); } catch (GoogleJsonResponseException e) { Log.d("YC", "Could not search: " + e.getMessage()); switch (e.getStatusCode()) { case 403: this.KEY = this.context.getString(R.string.api_key2); channelQuery.setKey(this.KEY); try { response = channelQuery.execute(); } catch (IOException e1) { Log.d("YC-KEY2", "Could not initialize: " + e1.getMessage()); } } } catch (IOException e) { e.printStackTrace(); } List<Channel> results = response.getItems(); for (Channel result : results) { channel.setChannel_id(this.channel_id); channel.setTitle(result.getSnippet().getTitle()); channel.setDescription(result.getSnippet().getDescription()); channel.setThumbnailURL(result.getSnippet().getThumbnails().getHigh().getUrl()); if (isTablet(this.context)) { channel.setBannerURL(result.getBrandingSettings().getImage().getBannerTabletImageUrl()); } else { channel.setBannerURL(result.getBrandingSettings().getImage().getBannerImageUrl()); } channel.setViewCount(result.getStatistics().getViewCount()); channel.setVideoCount(result.getStatistics().getVideoCount()); channel.setSubscriberCount(result.getStatistics().getSubscriberCount()); } }