Android create file from drawable -


is there way create file image drawable send via multypartentity? having error time.

fileuri =  uri.parse("android.resource://com.wellbread/drawable/placeholder_avatar.png"); mcurrentphotopath = fileuri.tostring();    java.io.filenotfoundexception: android.resource:/com.wellbread/drawable/placeholder_avatar.png: open failed: enoent (no such file or directory) 08-25 12:01:53.134    3663-3684/? w/system.err﹕ @ libcore.io.iobridge.open(iobridge.java:456) 

try following sample code:

        drawable drawable = getresources().getdrawable(r.drawable.ic_action_home);         if (drawable != null) {             bitmap bitmap = ((bitmapdrawable) drawable).getbitmap();             bytearrayoutputstream stream = new bytearrayoutputstream();             bitmap.compress(bitmap.compressformat.png, 100, stream);             final byte[] bitmapdata = stream.tobytearray();             string url = "http://10.0.2.2/api/fileupload";             multipartentitybuilder builder = multipartentitybuilder.create();             builder.setmode(httpmultipartmode.browser_compatible);              // add binary body             if (bitmapdata != null) {                 contenttype contenttype = contenttype.create("image/png");                 string filename = "ic_action_home.png";                 builder.addbinarybody("file", bitmapdata, contenttype, filename);                 httpentity = builder.build();                 ...             }         ...         } 

Comments

Popular posts from this blog

java - UnknownEntityTypeException: Unable to locate persister (Hibernate 5.0) -

python - ValueError: empty vocabulary; perhaps the documents only contain stop words -

ubuntu - collect2: fatal error: ld terminated with signal 9 [Killed] -