android - Thumbnail image is null when listing file from Google Drive -


i set thumbnail successfull

in same activity, used following code information related file, , file.getthumbnail() show encoded data, know.

private static void printfile(drive service, file file) {     system.out.println("title: " + file.gettitle());     system.out.println("getthumbnail: " + file.getthumbnail()); } 

but in activity (i use intent transfer), when list folder google drive, file.getthumbnail() null (use method printfile() again). i don't know why? following code listing files specified folder, successfull :

private void listfile(final drive service, final string folderid) {     new thread(new runnable() {          @override         public void run() {             files.list request;             try {                 request = service.files().list();                 // set id of specified folder                 request.setq(folderid);                 {                     try {                         filelist filelist = request.execute();                         request.setpagetoken(filelist.getnextpagetoken());                          // implement : list of files                         (file file : filelist.getitems()) {                             printfile(service, file);                              // todo thumb nail in here                             inputstream =                                      downloadthumbnailfile(managefiledriveactivity.mdriveservice, file);                               // don't need note method, because file.getthumnail() null                                                     }                     } catch (final ioexception e) {                         request.setpagetoken(null);                     }                 } while (request.getpagetoken() != null                         && request.getpagetoken().length() > 0);             } catch (final ioexception e1) {             }         }     }).start(); } 

p/s : - get file - file resource

please tell me how get thumb nail image successful. thanks!

update use following code, solution :

public static inputstream downloadthumbnailfile(drive service, file file)         throws ioexception {     if (file.getthumbnaillink() != null && !file.getthumbnaillink().isempty()) {         try {             system.out.println("getthumbnaillink: " + file.getthumbnaillink());             httpresponse resp = service.getrequestfactory()                     .buildgetrequest(new genericurl(file.getthumbnaillink()))                     .execute();              return resp.getcontent();         } catch (ioexception e) {             // error occurred.             e.printstacktrace();             return null;         }     } else {         // file doesn't have content stored on drive.         return null;     } } 

use file.getthumbnaillink(). thumbnail attribute write-only.


Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -