[英]How to process image once selected?
I'm retriving image from a IO file manager (one's installed). 我正在从IO文件管理器(已安装)中检索图像。 Anyhow when I try to retrieve an image I'm not sure where it's gone?
无论如何,当我尝试检索图像时,我不确定它去了哪里? Or how to save it as a bitmap?
或者如何将其另存为位图?
Code below: 代码如下:
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");
}
First of all, you are not overriding onActivityResult. 首先,您不会覆盖onActivityResult。 Note the method signature: http://developer.android.com/reference/android/app/Activity.html#onActivityResult(int , int, android.content.Intent)
请注意方法签名: http : //developer.android.com/reference/android/app/Activity.html#onActivityResult (int,int,android.content.Intent)
You should be using @Override annotations so you know when something's wrong. 您应该使用@Override批注,以便在出现问题时知道。
Try something like: 尝试类似的方法:
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);
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.