Youtube API impossible on android? - java

I've been having tremendous problems with connecting my android app to the youtube API. Firstly I tried to go along the route of using the native youtube gdata java client(http://code.google.com/p/gdata-java-client/). I had read that this could then be integrated into an android app easily enough and so I set about doing that but I would stumble every time at the line
YouTubeService ytservice = new YouTubeService("AppName",Dev_Key);
I'd enter the correct details here, even have all the necessary external jars but every time I would be given a NoClassDefFoundError reporting that YouTubeService could not be found and neither could it's superclass, MediaService. (Just so you know, I had gdata-youtube-2.0.jar, gdata-client-1.0.jar, gdata-media-1.0.jar, guava.11.0.2.jar and jsr305.jar)
So then I tried which appeared to support android (http://code.google.com/p/google-api-java-client/wiki/Android). There was even a sample example where google tasks had been integrated so it looked promising. It didn't have an actual YouTube class like it did have a taskService but it did support OAuth 2.0 login which I could work with by just sending off URL requests to the youtube API with OAuth 2.0 authentication. I tried this but when the only key I could get from it in combination with android's AccountManager was an auth key token. Posting this with the URL request to google resulted in an 'authentication required' response from youtube(because i was providing an incorrect access token, it was at least twice the size of a working access token i was comparing it with).
How can I find the access token that I need for the youtube API from the AccountManager? Or even better, how can I get the YouTubeservice to work?
Thanks
rory
Edit
Amad, thanks for the answer but unfortunately that is what i am already doing:
(source: themobilelook.com)
maybe it'll help if i supply my project folder: here it's a barebones setup, literally just to test if the YouTubeService works.
using adt 20, jdk compliance level 1.6
if you manage to create a working version then itnwoild be great if you could share it

The YouTube API library/libraries must be included in the project. By going to the Project Properties > Build Path > Order and Export tab, you can tick the checkbox next to the all YouTube-API-related libraries to ensure that they will be included in the project when you export it. Make sure to clean and rebuild after doing this.
As for the access token... not totally sure. The documentation may help there. This Google Groups thread may help also.

If you get NoClassDefFoundError during Runtime, then I suspect you did not include them to work at runtime. You have to check the checkbox for each .jar like this:
(Of course you have to add them to your java build path first)

Related

How to combine a standalone application with an Android application?

How do I combine a standalone Java application with an Android application?
I have a piece of code taken from the Google quick start examples that perform a task that I can't seem to be able to combine with my activity source code.
I'm of course talking about the following Google example: Sheet API, if I just add it as a standalone class and tell Android Studio to run this application, before my Android application, then it will produce what the code is suppose to do.
If I try to copy and paste the exact code into one of my activities it will give a couple of problems. One is that it can not find my keystore, another is a threading issue which I understand, another being that it can not find the credentials (even if the file is present), the newTrustedTransport-method call will be an issue, the setDataStoreFactory-method call will be an issue, file creation even with the correct uses-permissions and so on.
What is going on in the background that would make exactly the same source code work in one instance and not the other? What do I not know about Android Studio, and how an Android project works in the background for me having these issues?
I had an idea that I could just keep this standalone application as it is and store a file with the result that this Sheet example would provide me. But, since I do not have enough experience with Android Studio I have no idea if the result will be available for the actual Android application once it was made into a release. Will it? I can't save the output file generated by the Sheet example, under the res-folder, under the app module for some reason (scope?).
With other words... Can I have a standalone application, that is tasked to run before the Android application, to gather data and it will be doing this EACH time the Android application is run on a client? I feel like it would be stupid if the IDE would present this like this would actually work but then when the application is made into a release then the standalone application will not "follow" and be part of the release...
If I could just combine the source codes, I will not be having this issue at all. No examples online, neither Github or Youtube can provide me with answers on how to do this. Many examples online provide me with source code that is either out of date or just not what I'm looking for, and I really hate Google's way of explaining things. Just look at how they give code examples under this page: Google API Client Library for Java, and not give a full example where they would fit into the a project. Maybe all I need to make everything work is to use the code under "The library runs on Android 4.0 or higher (#Beta)."

Gitkit Java - Update photo URL

My goal is setting the URL for the profile picture of an existing user.
I'm using the Google Identity Toolkit Java library on App Engine.
Below is my code:
GitkitUser u = gitkitClient.getUserByLocalId(localId);
u.setPhotoUrl(profilePictureURL);
gitkitClient.updateUser(u);
where gitkitClient' is my GitKit client, already initialized with the right parameters, andlocalId' is the id of the user I'd like to update.
This code causes the following exception:
org.json.JSONException: JSONObject["localId"] not found.
Documentation is hard to find for this library. I'd be glad if someone could suggest me what I'm missing there.
Thanks for reporting the bug. It will be fixed in one or two days.
[UPDATE] It's fixed. I manually tested and verified. Please also use the newest version of java library. You can get it from here or from maven update.

Is the Google Drive web host link feature in danger of being phased out?

I am working on an Android app that stores log on a client's Google Drive. We push static HTML/Javascript files to said Drive in order for the user to be able to read their logs in an user friendly way via their browser. This feature worked relatively well until now (notwithstanding some glitches due to server updates in the last few months).
2 weeks ago (.e. from the beginning of October 2014) we saw that the newer user interface of Google Drive has dropped the web host link capability altogether. For legacy accounts this feature is still there, but not for newer created accounts from the aforementioned date.
Does that mean that Google is planning to ultimately drop this feature, or is it going to be available for the foreseeable future, even if only accessible programmatically via SDK?
Note that we tested to see if programmatic access is affected, and it seems to work fine. We used java SDK function getWebViewLink() (class File) in order to get the link programmatically, and it still works no 1 for now. But the change in UI from Google does worry us that this feature will be dropped, like Dropbox dropped theirs recently. Is that the case? If so, what is the expected timeline of feature deprecation and eventual disappearance?
It looks like they moved/changed it but didn't remove it altogether. The instructions from Google on how to host webpages with Drive worked for me using an account I created after the UI change (after you posted this question).
Since their latest blog post on deprecating APIs does not say anything about getting rid of the web host feature, you are probably fine.
If so, what is the expected timeline of feature deprecation and eventual disappearance?
If the APIs they're deprecating are anything to go by, even if they do get rid of web hosting it will be a couple of years between the time they announce it and it actually being unavailable. It's not a perfect comparison since those are entire APIs and this is just a feature but it doesn't seem like they make a habit of making something unavailable at the drop of a hat.

R.java file isn't being generated if I add the Facebook SDK to my app (that uses Parse)

I am working on an android project and wanted to integrate FB into it.
Using the FB SDK tutorial, I imported the FB SDK into my workspace along with a sample project. The sample project seems to have no problem with the FB library. But when I try to go to stick the library into my app, my app refuses to generate R.java. If I remove it, the R.java gets generated again.
I did a lot of googling and tried the common tricks like cleaning my project, checking for XML errors, etc.
I am now thinking it might be a problem with having both Facebook and Parse. Parse used to have Facebook SDK integrated, but they changed that recently and they now want you to import the Facebook SDK. I tried both not updating and updating Parse, but either way still not generating R.java.
I have set it so my min SDK is level 8 and the max is level 17. I tried raising and lowering the max, but it made no difference.
I have been working on this for the whole day but cannot figure out what is going on. Anyone having similar issues or have insight into the problem, I would very much appreciate feedback.
Edit: I do get this on the console: WARNING: unable to write jarlist cache file /Users/.../facebook-android-sdk-3.6.0/facebook/bin/jarlist.cache
Edit 2: I think I figured out the reason: http://www.reddit.com/r/androiddev/comments/1xajcp/too_many_methods_for_dalvik_help/

Java Google Alert API

Google does not provide any API for Google Alert create, update, list, delete operations. I need to build java application to manage the alerts with create, update, list, delete operations through program.
I have done some research in the internet and tried to put across the code in Java but does not seem to be working.
Approach Taken - Client Login into Google (works) and then Http Post to create alert (does not work), and then parse html to comprehend the list of alerts (this can be made to work - not coded yet)
I know there are few solution on the web for a fee. However I do not want to rely on other's closed source.
Any solution will be of great help
You can find a java library for creating, listing and deleting google alerts here: http://www.coders11.com/googlealertsapi/index.php
It works perfectly, the only problem is that it became commercial.
You can try this API, that is java library.
https://github.com/nnhiti/google-alert-api

Categories