我正在从IO文件管理器(已安装)中重新获取图像。无论如何,当我尝试检索图像时,我不知道它在哪里消失了?或者如何将其保存为位图?
以下代码:
public void onClick(View v)
{
if(v.getId() == R.id.facebook_icon || v.getId() == R.id.facebook_text)
{
//Facebook
}
if(v.getId() == R.id.camera_icon || v.getId() == R.id.camera_text)
{
//Camera
}
if(v.getId() == R.id.folder_icon || v.getId() == R.id.folder_text)
{
Intent intent = new Intent();
intent.setType("image/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(Intent.createChooser(intent,"Select Picture"), MODE_WORLD_READABLE);
}
}
protected void onActivityForResult()
{
//Where is the image? How to get?
System.out.println("Image gotton");
}
答案 0 :(得分:1)
首先,你没有覆盖onActivityResult。请注意方法签名:http://developer.android.com/reference/android/app/Activity.html#onActivityResult(int,int,android.content.Intent)
您应该使用@Override注释,以便在出现问题时知道。
尝试类似:
public void onActivityResult(int requestCode, int resultCode, Intent data)
{
super.onActivityResult(requestCode, resultCode, data);
if (resultCode == RESULT_OK)
{
Uri imageUri = data.getData();
Bitmap bitmap = MediaStore.Images.Media.getBitmap(this.getContentResolver(), imageUri);
}
}