I have uploaded a file on google drive, i have made it public. i am able to access this on browser but not with my android app.
I need to access this public link on MY ANDROID APP.
PFB the link of file:
https://drive.google.com/file/d/0B56C1LC3IVXCV055WFIyVTZjTTA/edit?usp=docslist_api
Is this possible to access a publicly shared GD file on android app?
Code snippet is
URL url = new URL("https://drive.google.com/file/d/0B56C1LC3IVXCV055WFIyVTZjTTA/edit?usp=docslist_api");
Bitmap bmp = BitmapFactory.decodeStream(url.openConnection().getInputStream());
return bmp;
The solution is to format the address of the document you have shared.
Check this :
URL = "https://docs.google.com/uc?id=" + IDFile + "&export=download";
Your link is not to image but to Google Drive App with this image opened, real URL to image is this
Consider using Google Drive API
How about scaling the picture down to a reasonable size, it may just be that the image is too large for your heap to load
Bitmap.createScaledBitmap(Bitmap src, int Width, int Height, boolean filter)
There one other way to access file's public link By adding :
https://googledrive.com/host/[folderId]/fileName.extension
As you have provide file url
You can use that url like this for public access
https://googledrive.com/host/0B56C1LC3IVXCV055WFIyVTZjTTA
You simply need to grab the webContentLink of the newly created file.
From the documentation ...
webContentLink string
A link for downloading the content of the file in a browser using cookie based authentication. In cases where the content is shared publicly, the content can be downloaded without any credentials.
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 using Fresco library to display images in my Android app. I'd like to display some images (jpg or png) that I have set with public grants.
When I was doing quick tests, I just took any image from internet to set a URL, but when using the real ones that I need to use, I have the following url https://drive.google.com/uc?export=view&id=<>, but as it is a redirect and, once redirected, new url is not the image itself, Fresco is unable to display it.
I have tried Picasso as an alternative library, but with out any success.
I have also tried the download url for both libraries (https://drive.google.com/uc?export=download&id=<>). But no result.
Anybody knows how could it be possible to get this images? Or the only solution is to download it (using the second url) processing the object received store a bitmap of it and displaying it?
For downloading it, what should i use and how? retrofit?
Thanks in advance.
Fresco supports different network stacks. For example, you can use OkHttp with Fresco, which should follow redirects or modify the default one to allow redirects - or write your own based on them.
Guide for OkHttp: http://frescolib.org/docs/using-other-network-layers.html
Related GitHub issue: https://github.com/facebook/fresco/issues/61
I found a solution for this problem (but could be only applicable if you use Google Cloud or Google Script).
It consists on creating a doGet() service with the following code inside:
var file = DriveApp.getFileById(fileId)
return Utilities.base64Encode(file.getBlob().getBytes());
and use that base64 value in your app. With this format, Fresco can do the magic
It is not an immediate solution, and requires to do somework in other platform that is not your Android app, but it works perfectly.
Are you sure that there is no problems with your URLs?
Picasso works with direct URLs like: https://kudago.com/media/images/place/06/66/06662fda6309ce1ee9116d13bd1c66d5.jpg
Then you can download your image like:
Picasso.with(this)
.load(url)
.noFade()
.placeholder(R.drawable.placeholder_grey) //if you want to use a stub
.into(imageView, new com.squareup.picasso.Callback() {
#Override
public void onSuccess() {
//here you can operate with image after it is downloaded
}
#Override
public void onError() {
}
});
Hope it will help you.
Is there a way to download just the icons that are stored in a particular application from Google Play/Market without downloading the entire APK and installing it?
You can do this but it would require downloading he page source and then parsing it.
What you could do is first download the webpage, i like JSoup. Like
Document d = null;
try {
d = Jsoup.connect("https://play.google.com/store/apps/details?id=" + packageName).get();
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
Then you should parse that document for the following tag ""
Elements div = d.getElementsByAttributeValueContaining("class", "doc-banner-icon");
String path = div.get(0).attr("src");
This path variable should be the path for the image to download. I have not tested this.
Nope
There is no official API for market content. Be it to retrieve icons or anything else.
If you are just interested in getting the image files you can download them manually via the web front end to the Market. But I wouldn't write code to do this, as it is very likely that they will make a change to the web front end that will result in your code breaking. p.s. I am no lawyer, but also I don't think there is very much that you would be "allowed" to do with these images even if you did download them (without permission from each developer of course)
The answer by Jug6ernaut will no longer work. This works as of November 2016:
#WorkerThread public static String scrapeGooglePlayIcon(#NonNull String packageName) throws IOException {
return Jsoup.connect("https://play.google.com/store/apps/details?id=" + packageName).get()
.select("div[class=details-info] > div[class=cover-container] > img[class=cover-image]")
.attr("abs:src");
}
I created a small library that web scrapes the Google Play store. If this stops working in the future, please comment or create an issue on the GitHub project: https://github.com/jaredrummler/GooglePlayScraper
You could create a Yahoo Pipes like this http://kcy.me/hylg it will parse the page for you and extract a JSON in wich you could read the sinlge image URL.
http://kcy.me/hylj
You can parameterize the pipe in order to receive the link to the app you want to extract the image.
The simple solution is that just right click on the icon of the app from Chrom browser and save image as, this will save the icon with webp extension, now use this Conver webp to png
to convert the icon to PNG.
I'm using an API in my Android app that downloads images from the web and shows a placeholder animation while the images are downloading (RemoteImageView, part of the Ignition package here.
At some points in the app, I need to show images from the local resource drawables and not downloaded from the web.
Is it possible to access the local resource drawables using a URL ?
The way to do it:
use this line "android.resource://[your package]/"+[res id]
Here is an example
Uri myURI = Uri.parse("android.resource://com.example.project/" + R.drawable.myimage);
for convenient you can use it as a method:
public static Uri getUrl(int res){
return Uri.parse("android.resource://com.example.project/" + res);
}
Warning do not use context.getPackageName() as substitute to package name because it might return a null value.
Local image resources do not have urls, they have URIs. So if you have image in drawable, you can parse them from resource id to URI.
Uri uri=Uri.parse("R.drawable.image");
However, if you can also put your images in asset folder of the package and access them using their URL. The URL of the image files would be "file:///android_asset/image.png"
You can use either of the option.
I am developing an application for Android and which uses Dropbox for organizing the files. I am exploring the Dropbox API but its description and help is limited, as there is no documentation for the Dropbox API.
I still would like to manage the files to some functionality, for example placing a file and getting a file from Dropbox. Now the problem is when I put some files in Dropbox public folder and I need a URL to share to my contacts in the application. But in the API I could not find any function that returns the web URL of the file to share (Just like in the Deskotop interface of Dropbox, a user can get a Shared URL to send to friends).
Could someone help me figure out how to share that file with contacts in the Application?
Or any other way to share a file using Dropbox Android API?
According to changes made on DropBox metioned here: https://www.dropbox.com/help/16/en
There would be no more Public folders, instead access to files can be done via Share Link.
If you use Android DropBox Core Api then shared link can be retrieved this way:
// Get the metadata for a directory
Entry dirent = mApi.metadata(mPath, 1000, null, true, null);
for (Entry ent : dirent.contents) {
String shareAddress = null;
if (!ent.isDir) {
DropboxLink shareLink = mApi.share(ent.path);
shareAddress = getShareURL(shareLink.url).replaceFirst("https://www", "https://dl");
Log.d(TAG, "dropbox share link " + shareAddress);
}
}
UPDATE: 2014/07/20 by Dheeraj Bhaskar
Use the following helper function alongwith the above function.
Since DropBox started to send shortened links it is little bit more problematic to get proper link.
For now, I am using this method :
We simply load the URL, follow the redirects and get the new URL.
String getShareURL(String strURL) {
URLConnection conn = null;
String redirectedUrl = null;
try {
URL inputURL = new URL(strURL);
conn = inputURL.openConnection();
conn.connect();
InputStream is = conn.getInputStream();
System.out.println("Redirected URL: " + conn.getURL());
redirectedUrl = conn.getURL().toString();
is.close();
} catch (MalformedURLException e) {
Log.d(TAG, "Please input a valid URL");
} catch (IOException ioe) {
Log.d(TAG, "Can not connect to the URL");
}
return redirectedUrl;
}
Note: All of this should be done of course in AsyncTask or Thread. This will produce proper links ready to download
Update 2014/07/25: Change in dropbox share URLs
A heads-up on the kind of URLs to expect
From the Dropbox team:
We wanted to give you a heads up about an upcoming change to the URL
structure of Dropbox shared links. While not part of the API, the
change could affect apps that manipulate the URLs returned from the
/shares endpoint or the "preview" link type returned by the Chooser
Drop-in.
Links returned will now have a ?dl=0 appended to them.
E.g., instead of
https://www.dropbox.com/s/99eqbiuiepa8y7n/Fluffbeast.docx, you'll
receive URLs
like this link
https://www.dropbox.com/s/99eqbiuiepa8y7n/Fluffbeast.docx?dl=0.
A useful thread in the Dropbox forums:
http://forums.dropbox.com/topic.php?id=37700&replies=7#post-326432
IF The public link for a file is always
dl.dropbox.com/u/<your users uid>/<path under /Public>/filename
then we can just use the API to get and build the public URL in the code.
Perhaps this may also help: Upload a file to Dropbox and copy public address. This script upload a file to your /Public directory and use your accound
UID to build it's public URL. Then, it echoes the URL to the console.
https://github.com/sylvainfilteau/dropbox-api-command/commit/6aa817c79220c5de4ff5339cd01ea8b528bcac36
I am not there yet in my Dropbox interface implementation, but this is one of the functions I need to develop. More in one or two days I hope.
I believe the url is as follows:
http://dl.dropbox.com/u/YOUR_DROPBOX_ID/YOUR_FILE_NAME