android - unable to get correct path of a video -


i want application pick video gallery. uses following code path.

intent = new intent(intent.action_get_content);  i.settype("video/*");  startactivityforresult(i,2);  

and

 @override  protected void onactivityresult(int requestcode, int resultcode, intent data) {  // todo auto-generated method stub    if(resultcode==result_ok){        str = data.getdata().getpath();    //this.go();       this.ko();   }  } 

str stores path. test run value /external/video/media/10 should /sdcard/dcim/a.mp4 load video using mediametadataretriever. how ?

in case, (as understand question)

if(resultcode==result_ok){       str = getrealpathfromuri(data.getdata());    //this.go();       this.ko();   } 

use, function real path uri..

function:

public string getrealpathfromuri(uri contenturi)     {         try         {             string[] proj = {mediastore.video.media.data};             cursor cursor = managedquery(contenturi, proj, null, null, null);             int column_index = cursor.getcolumnindexorthrow(mediastore.video.media.data);             cursor.movetofirst();             return cursor.getstring(column_index);         }         catch (exception e)         {             return contenturi.getpath();         }     } 

Comments

Popular posts from this blog

django - How can I change user group without delete record -

java - Need to add SOAP security token -

java - EclipseLink JPA Object is not a known entity type -