bitmap - Android video thumbnail is null -


so i'm trying achieve user can choose select existing video or take new one, bitmap has null value.

@override protected void onactivityresult(int requestcode, int resultcode, intent data) {     if (requestcode == request_video_capture && resultcode == result_ok || requestcode == select_video && resultcode == result_ok) {         uri selectedvideo = data.getdata();         addvideototable(thumbnailutils.createvideothumbnail(selectedvideo.getpath(), mediastore.video.thumbnails.mini_kind));     } }  public void addvideototable(bitmap video) {     tablelayout tl = (tablelayout)findviewbyid(r.id.videotable);     if (videocount == 0 || videocount % 3 == 0) {         tr = new tablerow(this);         tr.setlayoutparams(new tablerow.layoutparams(tablerow.layoutparams.fill_parent, tablerow.layoutparams.wrap_content, gravity.center_horizontal));         tl.addview(tr);     }     imageview iv = new imageview(this);     iv.setimagebitmap(video);     iv.setpadding(0, 0, 10, 10);     iv.setlayoutparams(new tablerow.layoutparams(tablerow.layoutparams.wrap_content, 300, 1f));     tr.addview(iv);     videocount++; } 

try:

public string getpathfromuri(uri uri) {     cursor cursor = getcontentresolver().query(uri, null, null, null, null);      //source not device capture or selection     if (cursor == null) {          return uri.getpath();     } else {         cursor.movetofirst();         int idx = cursor.getcolumnindex(mediastore.mediacolumns.data);         if ( idx == -1 ) {             return uri.getpath();     }      string path =  cursor.getstring(idx);     cursor.close();     return path; } 

this should work when select local video either capture, or stored on user's device. reason isn't working you getting raw path, rather path in media store method thumbnailutils uses.


Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -