我正在尝试将由画廊或相机选择的 m 图像发送到另一个活动,但似乎没有发生任何事情,我已将位图转换为字符串以通过意图发送它,但似乎从未调用过意图。
请帮助我我做错了什么?
这是我的 onActivityResult() 代码
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
Bitmap thumbnail = null;
if(requestCode==RESULT_LOAD_IMAGE){
if(resultCode==RESULT_OK){
Uri selectedImageUri = data.getData();
String[] filePathColumn = { MediaStore.Images.Media.DATA };
Cursor cursor = getContentResolver().query(selectedImageUri,filePathColumn, null, null, null);
cursor.moveToFirst();
int columnIndex = cursor.getColumnIndex(filePathColumn[0]);
String picturePath = cursor.getString(columnIndex);
cursor.close();
data.getExtras().get("data");
thumbnail = (BitmapFactory.decodeFile(picturePath));
//CONVERT BITMAP TO STRING
ByteArrayOutputStream baos=new ByteArrayOutputStream();
thumbnail.compress(Bitmap.CompressFormat.PNG,100, baos);
byte [] b=baos.toByteArray();
String temp=Base64.encodeToString(b, Base64.DEFAULT);
//trying to start activity...
Intent intent = new Intent(Home.this, Upload.class);
intent.putExtra("picture", temp);
startActivity(intent);}
}
}
}