I am developing an Android application that needs to search for a YouTube video by keyword. I used the Youtube data API with the code below:
try { youtube = new YouTube.Builder(Auth.HTTP_TRANSPORT, Auth.JSON_FACTORY, new HttpRequestInitializer() { public void initialize(HttpRequest request) throws IOException { } }).setApplicationName("YoutubeQoE").build(); // Define the API request for retrieving search results. YouTube.Search.List search = youtube.search().list("id,snippet"); // Set your developer key from the Google Cloud Console for // non-authenticated requests. See: // https://cloud.google.com/console search.setKey(DeveloperKey.DEVELOPER_KEY); search.setQ("dogs"); // Restrict the search results to only include videos. See: // https://developers.google.com/youtube/v3/docs/search/list
For de DEVELOPER_KEY, I used the open API on the Google Developer Console.
But when I run the program, there is a problem in the line:
SearchListResponse searchResponse = search.execute ();
In android manifest.xml, I have these permissions:
<uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
I would really appreciate if anyone can help me
android youtube youtube-api android-youtube-api
josesvm
source share