我正在尝试从相机或画廊加载图像(不是 URL)并将其保存到全局类。(目前我正在尝试获取图像,尚未定义类)。
所以我认为相机正确返回图像,并将其放入捆绑包中,如果可能的话,我喜欢对画廊使用相同的方法。
所以我有:
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
// TODO Auto-generated method stub
super.onActivityResult(requestCode, resultCode, data);
if(resultCode==RESULT_OK){
Bundle extras = data.getExtras();
bmp = (Bitmap) extras.get("data");
}
}
而这两个选择,显然我在画廊做错了什么:
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
// TODO Auto-generated method stub
switch(arg2){
case 0:
i = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(i, cameraData);
break;
case 1:
Intent intent = new Intent( Intent.ACTION_GET_CONTENT );
intent.setType( "image/*" );
//i = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
startActivityForResult(intent, 10);
break;
}
我收到失败的结果:资源上的空指针异常:dat=content://media/external/images/media/23
所以我想我做错了什么。
Idea is similar to behavior seen in Instagram, take photo or select existing one, and when selected it should be stored in some singletone object, as I'll have 3 more options that can be selected before image is shown again within my app.
我不确定这是否是处理图像的最佳方式,所以这里也欢迎任何建议。
肿瘤坏死因子