How to display an photo from Google Drive in Android app? - android

Im currently using Google Drive REST API in order to create folder/files in my Drive.
However i would like to know how could i use the rest api to display an image from Drive in my app ? Is that even possible ?
iv = (ImageView) myFragmentView.findViewById(R.id.imageView1);
iv.setImageURI(Uri.parse("https://drive.google.com/uc?export=view&id={fileid}"));
This doesnt work i have nothing displayed on my screen.

I've not been able to figure out a way of doing this using the id or the URL...
However, if you are using the Google Script, you could try a solution similar to this:
var file = DriveApp.getFileById(fileId)
var base64CodedFile = Utilities.base64Encode(file.getBlob().getBytes());
and use that base64 variable to be sent to your app. With this format you will find a way of displaying your images (don't know Picasso, but Fresco library can do it easily...)
It is not an immediate solution, and requires to do somework in other platform that is not your Android app, but it works perfectly.

Related

Fetch Image without URL in Android

I'm developing an app and one of the components involves the user recording where they have gone for the day. I use some NLP to identify the location, however it would be awesome if I could also after obtaining the location or any other string for that matter get an image from an external API. I've seen people use image urls to get images for their android app but, how can I get an image without a URL, kind of of like a google images search? If this isn't possible is there a way to get an image url?
You can use Google Images Api:
https://serpapi.com/images-results

Android: Loading image from public Google Drive folder into ImageView working randomly

I'm working on an app that displays images stored in my personal Google Drive account in a public folder, and I access them and load into ImageView with the next url:
https://drive.google.com/uc?export=download&id=imageId
And so I use the next piece of code to load an image into an ImageView using Picasso:
String imageLink="https://drive.google.com/uc?export=download&id="+imageId;
ImageView imageView = (ImageView) findViewById(R.id.imageView);
Picasso.with(this).load(imageLink).into(imageView);
And it was working fine until yesterday, from when it started to work randomly, let's say, sometimes image is loaded and sometimes not and you simply see a blank ImageView (don't know the reason).
It's really weird, because when it stops working then it stops working for a while, and then, after many attempts it can suddenly start working again and so :s
I've also tried the next url with same results:
https://drive.google.com/uc?id=imageId
I guess it could be a better to implement Google Drive Rest API into my app, but I was reading the documentation and I don't find it trivial, so decided to give up.
I prefer to use just the url method because it's much simpler, but in case you think API is the only solution a working example would be much appreciated.
BTW; if I use the url in a browser the image is displayed/downloaded correctly, athought it is converted to something like this:
https://doc-0g-bs-docs.googleusercontent.com/docs/securesc/76n246a8a2lbkhsdab1lp67gphlf8cpm/i1ue4k811iltbcb797njulf061flfdpg/2581292320200/05260912172022660129/05860924272025660129/10_DnmLE22AvRB2eRHaTi8RLCrgVopoHC?authuser=0&nonce=2td2b6i2brn2u&user=02222914122025660129&hash=2odo2ssceotbocirunbn4vqj26l2h6fl
Any help?
Edit: I noted that Google Drive response is a plain http 403 error with no additional description (or at least Picasso Exception won't show additional data).
Edit1: I suspect it may have something to do with Internet connection. When it stops working (returning the 403) if I reboot my phone it starts working again (only with data connection, not with wifi). Maybe Google Drive is blocking my mobile connection ip after many requests (or at least is the only thing that come to my mind).
Edit2: Maybe it's only me that I'm doing many tests/requests from the same ip and that's why Google Drive blocks my ip or maybe it's a general issue and if plenty of users do requests at the same time the same will happen? I need to find a solution, and if there is no one (wouldn't believe that) at least advices on other free image hosting services I can use to load images in my app (into an ImageView) from the cloud.

Uploading to Blobstore - Android

I am trying to create an Android app where people can read short stories. The stories will be in the form of images since it will include some arts to accompany the text. That is the reason of why I decided to use Google App Engine. I want to store the images in the App Engine then let the client device retrieve all the stories(or images). I can then somehow organise the images into the proper sequence (which I have not an idea on how to do).
I am completely new to Cloud computing or doing backend stuff so there is a lot of stuff that I am not wrapping my head around.
I did a tutorial on creating a mobile assistant app. In the end I got it working and deployed to App Engine. Whenever I upload the files I did it through the command line using "appcfg.py" however after looking at Blobstorage it seems to work a bit differently.
How exactly do you upload images to Blobstore? So far all the thing I've read is on uploading data from the client device/web application and I can't seem to find anything that is very detailed on using Blobstore and Android together. What I am trying to ask is, is there a way to upload the images to the Blobstore directly from the command line (if that is possible)? And how to handle those images once it's up in Blobstore?
Can someone give me some advice please?

Display Google Places photos in android device

Hi I'm working on Google Places API, with Google Places Photo request I can get different images of a specific place. But I don't know how to display this image in a android device.
This is the request URL that I'm using to retrieve the image
https://maps.googleapis.com/maps/api/place/photo?maxwidth=400&photoreference=CoQBegAAAFg5U0y-iQEtUVMfqw4KpXYe60QwJC-wl59NZlcaxSQZNgAhGrjmUKD2NkXatfQF1QRap-PQCx3kMfsKQCcxtkZqQ&sensor=true&key=AddYourOwnKeyHere
Need some help on this..
https://github.com/koush/UrlImageViewHelper
include the library in your project.
and use the following code
UrlImageViewHelper.setUrlDrawable(imageView, "YOUR URL HERE");
its very simple

Google Drive OCR Android

I've downloaded Google drive sdk for Android,
the API is not well documented, so I didn't manage to get to conclusion if what I want to do is possible.
I want to capture an image with the camera convert it to black and white pdf, and then perform OCR on it to get the fields I need as String.
Do I need to send a server request for it or maybe I can Do it on the client side only using Drive api?
sample code will be helpful.
Google's docs don't specify what happens to an uploaded file when you request OCR, specifically, they don't tell you if there is a response string.
However, a little experimenting shows that the only way to get the OCR data is to lookup the document after OCR is complete and grab the text.
You'll find the data structure for 'Files' here: https://developers.google.com/drive/v2/reference/files#resource - what your are after will be in "indexableText" as a string.
Unfortunately, it won't parse out any sort of 'fields'. That would require an understanding of the content... Also, it doesn't seem to capture any email addresses, which is an issue if you are trying to do business cards.
BTW, you will have to wait some time, upto 2 minutes, before the data is available. I'm not entirely sure, but it could also be that object id will not be available for that amount of time, so you might have to either run a background process or do something else.
Sorry that you didn't find the documentation, it is plentiful and available here: https://developers.google.com/drive/
The entire Drive API functions by making server calls, please check here: https://developers.google.com/drive/v2/reference/files/insert for how to perform OCR on uploading files to Drive. Look at the cunningly named "ocr" parameter.

Categories

Resources