Sub*_*ddy 8 xml base64 encoding android encode
我想将图像转换为base 64 encode to string.从那里发送到oma_status-icon
xml格式的服务器.
但我从服务器响应中得到不受支持的编码....
有没有其他方法将图像转换为base64字符串?
plz..help ...
我的代码是:
Bitmap bitmapOrg = BitmapFactory.decodeResource(getResources(), R.drawable.image);
ByteArrayOutputStream bao = new ByteArrayOutputStream();
bitmapOrg.compress(Bitmap.CompressFormat.JPEG, 100, bao);
byte [] ba = bao.toByteArray();
String ba1=Base64.encodeBytes(ba);
Run Code Online (Sandbox Code Playgroud)
Nik*_*hil 15
请使用此代码..
Bitmap bitmapOrg = BitmapFactory.decodeResource(getResources(), R.drawable.image);
ByteArrayOutputStream bao = new ByteArrayOutputStream();
bitmapOrg.compress(Bitmap.CompressFormat.JPEG, 100, bao);
byte [] ba = bao.toByteArray();
String ba1=Base64.encodeToString(ba,Base64.DEFAULT);
Run Code Online (Sandbox Code Playgroud)
请导入
import android.util.Base64;
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
20284 次 |
最近记录: |