hello am trying to get images from an album from picasa in an android app. I tried creating an album and the album was created successfully however there is something wrong when i try to get the images in the album. Please find below my code:
PicasawebService myService = new PicasawebService("myApp");
myService.setUserCredentials("username", "password");
URL url = new URL ("https://picasaweb.google.com/data/feed/api/user/myusername/albumid/myalbumid");
AlbumFeed feed= myService.getFeed(url, AlbumFeed.class);
List<MediaContent> l;
for(PhotoEntry photo : feed.getPhotoEntries()){
l= photo.getMediaContents();
return l.get(0).getUrl().toString();
}
the for loop is not being entered but when i check the size of the feed and it shows me the correct number of images in the album. I got the code from google developers guide:(https://developers.google.com/picasa-web/docs/2.0/developers_guide_java#listalbums)
NB: i tried the same exact code in a desktop app and worked perfectly.
Thank you
EDIT: The problem is that the ALbumFeed is returning entries of class GPhotoEntry and not PhotoEntry. I searched online and the solution was to include the gdata-photos-meta.jar in my library which was already included...Any idea?
google's GData doesnt work with android. You should use google Client api and they say that there is a running sample for picasa on android.
Related
I'm trying to parse an img src that is featured on a website and include it into my app. I'm using the flutter package Web Scraper, this is the code I've tried so far:
final webScraper = WebScraper('https://tiktok.com');
if(await webScraper.loadWebPage('/#$enteredUsername')){
tiktokProfilePictureURL = webScraper.getElement('img', ['src']);
print(tiktokProfilePictureURL);
}
The image I'm trying to get the URL from is the profile picture of the account, as shown in the screenshot below.
When I look into the code of the website it provides the link to the website image but when I try to parse this in web scraper it can't seem to find it.
This is the WebScraper output:
As you can see it finds various .svg images but not the .jpeg profile picture I'm trying to find.
Or maybe there is another way to parse this image src url? Any suggestions? Thanks.
I'm developing an app with Android Studio, I'd like to create a RecyclerView where I have an ImageView and upload a static image of a determining point on the map.
Like here: https://developers.google.com/maps/documentation/maps-static/intro
I tried to use this method with Picasso (Library that takes an image of a url and loads an ImageView) but nothing happens, with other urls of images on the internet that I used to test it worked and loaded in ImageView but with that nothing appears:
imageMap = findViewById(R.id.imageMap);
String lat = "-12.958811";
String lon = "-38.401606";
String url ="https://maps.googleapis.com/maps/api/staticmap?";
url+="&zoom=14";
url+="&size=330x130";
url+="&maptype=roadmap";
url+="&markers=color:green%7Clabel:G%7C"+lat+", "+lon;
url+="&key=MY_KEY";
Picasso.get().load(url).into(imageMap);
Does anyone know how to do this? With this or another method?
I have tried the methods in other posts reporting this problem but my url is correct in relation to the others.
Make sure you're using the right API key (use the one specifically for Android) and get a more detailed stacktrace by adding a simple success/error callback: Android: Picasso load image failed . how to show error message
You need to enable the billing option in your project. Google change the payment methods and now you need to enable this option in order to use some APIs.
In my project i need to include searchs to a API Rest to query with a url that points to a jpg picture and it returns a list of urls with similar pictures.
Google Images performs via web like i am looking for, but the clients for Android that i have found (github projects) they work simply with an input text.
The simplest code would be something as below:
String inputUrlPic = "https://cdn.pixabay.com/photo/2014/03/14/20/13/dog-287420__340.jpg";
String[] returnedUrlPictures = null; //list of returned pictures similars to inputUrlPic
ReverseImageApi reverseImageApi = new ReverseImageApi();//My desired Api object
returnedUrlPictures = reverseImageApi.findSimilarPicturesFromUrl(inputUrlPic); //Ok, it would be an asynctask
So, my question is, exists a API or an Android client API to perform in this way?
I want to upload a photo to picasa web album through from android using data api. i see this link https://developers.google.com/picasa-web/docs/2.0/developers_guide_java but this does not help me at all. can any one give an example code to upload a photo to picasa web album or other tutorial. Thanks
This is the official code sample for uploading a Image,
URL albumPostUrl = new URL("https://picasaweb.google.com/data/feed/api/user/username/albumid/albumid");
PhotoEntry myPhoto = new PhotoEntry();
myPhoto.setTitle(new PlainTextConstruct("Puppies FTW"));
myPhoto.setDescription(new PlainTextConstruct("Puppies are the greatest."));
myPhoto.setClient("myClientName");
MediaFileSource myMedia = new MediaFileSource(new File("/home/liz/puppies.jpg"), "image/jpeg");
myPhoto.setMediaSource(myMedia);
PhotoEntry returnedPhoto = myService.insert(albumPostUrl, myPhoto);
A complete example code is available here,
Connect to Picasa album from Android using OAuth2
So i am trying to display facebook photos from an album in and Android app.
The problem i am having is if i call this:
facebookAsyncRunner.request(albumId + "/photos", new UserAlbumPhotosFetchListener(JSONResponse, photoView));
i get a JSONResponse of an array of 25 photos. However, i need more than just 25 photos... i need all of them in the album. So i tried calling this:
facebookAsyncRunner.request(albumId + "/photos?limit=50", new UserAlbumPhotosFetchListener(JSONResponse, photoView));
in an attempt to get 50 photos instead of 25. This did not work. Instead i got nothing.
I also tried calling this same thing with limit=0, but this is giving me the same result.
to be specific: JSONResponse.getJSONArray("data") = []
Does anyone have any idea of what is happening/ how to request more than just 25 photos from an album?
thanks!
EDIT: I found a solution!
Bundle params = new Bundle();
params.putString("limit", "10");
facebookAsyncRunner.request(albumId + "/photos", params, new UserAlbumPhotosFetchListener(JSONResponse, photoView));
I have posted an answer which integrates pagination for an Endless Scrolling List here:
https://stackoverflow.com/a/13265776/450534
It is too big to post all over again, so am linking to the original answer instead. The answer is literally a complete a solution on how to make a Facebook query to an Album, fetch all photos (limited initially with a limit=10) and then fetching additional photos from the album when the user has scrolled down to the end and adding them to the existing list of Photos already fetched.
It uses a GridView instead of a ListView but the logic remain the exact same.
Alternatively, if you are looking only for a way to fetch Photos, here is a far simpler solution to get you started.
try {
String test = Utility.mFacebook.request("/10151498156121729/photos&access_token=YOUR_ACCESS_TOKEN?limit=1");
Log.e("TEST", test);
} catch (Exception e) {
// TODO: handle exception
}
The Album ID (10151498156121729) used in the code block above, is a Facebook Public Album.
I use the Utility class from the pre-3.0 Facebook SDK's HackBook example. If you are using the 3.0 SDK, I think you will need to substitute the Utility.mFacebook.request bit with an instance of the Facebook class
You should need to use Pagination for getting more than 25 photos. You can get only 25 items as result for a single query. To load the next 25 you should use the code like below:
facebookAsyncRunner.request(albumId + "/photos?offset=25&limit=25", new UserAlbumPhotosFetchListener(JSONResponse, photoView));
this will return the next 25 items, in this case the photos from 25th position to 50th position.
Try in this way..
Hope this may solve your problem.