I did search but can't find useful answer in the internet. That is why I raise the query.
I like to load the camera and capture image in the getView
method of a custom ArrayAdapter class. Camera is loaded and capture image but onActivityResult()
is never called. My code is as shown below.
public View getView(int position, View convertView, ViewGroup parent) {
View vi=convertView;
ViewHolder viewHolder=new ViewHolder();
LayoutInflater inflater = (LayoutInflater) this.getContext()
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
if(vi==null){
vi = inflater.inflate(R.layout.list_row, parent, false);
viewHolder.id=(TextView)vi.findViewById(R.id.title);
viewHolder.thumbnailImage=(ImageView)vi.findViewById(R.id.list_image);
viewHolder.arrow=(ImageView)vi.findViewById(R.id.list_arrow);
vi.setTag(viewHolder);
}
else
viewHolder=(ViewHolder) vi.getTag();
// Setting all values in listview
viewHolder.id.setText(listIDs.get(position));
viewHolder.thumbnailImage.setOnClickListener(new OnClickListener(){
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
((Activity)context).startActivityForResult(cameraIntent, CAMERA_REQUEST);
}
});
return vi;
}
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == CAMERA_REQUEST && resultCode == RESULT_OK) {
// Bitmap photo = (Bitmap) data.getExtras().get("data");
// imageView.setImageBitmap(photo);
}
}
Then the custom adapter class is activated from the ListFragment
class as
customList_Adaptor adapter = new customList_Adaptor(
getActivity(), R.layout.list_row, listIDs);
How can I modify so that onActivityResult() method is called. Thanks