我有一个xml布局,其中有一个按钮和一个文本字段。我在文本字段中填写了一些消息。现在,当我点击按钮时,我需要访问图库并选择图像。如何将邮件加密到此图像并再次保存到我的图库?此外,所有类型的加密都可以在此图像上完成,如AES
按钮调用Selimg()函数,当我点击它时,它应该打开画廊供我选择图像。该图片应存储在&缩图'中。这样我就可以进一步加密它了。到目前为止,这是我的代码:
公共类EncryptActivity扩展了Activity {
private static int RESULT_LOAD_IMAGE = 1;
private static final int PICK_FROM_GALLERY = 2;
Bitmap thumbnail = null;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.act_encrypt);
}
public void Selimg(){
Intent in = new Intent(Intent.ACTION_PICK,android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
startActivityForResult(in, RESULT_LOAD_IMAGE);
}
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == RESULT_LOAD_IMAGE && resultCode == RESULT_OK && null != data){
Uri selectedImage = data.getData();
String[] filePathColumn = { MediaStore.Images.Media.DATA };
Cursor cursor = getContentResolver().query(selectedImage,filePathColumn, null, null, null);
cursor.moveToFirst();
int columnIndex = cursor.getColumnIndex(filePathColumn[0]);
String picturePath = cursor.getString(columnIndex);
cursor.close();
thumbnail = (BitmapFactory.decodeFile(picturePath));
} }