1

I'm working on developing an android application for viewing dicom images which I have stored in an arrayList of Bitmaps, and I used a GridViewAdapter to preview the images in a GridView which is located in a fragment, then the user selects one image to see it in a new activity and that was done by implementing the onItemClickListner.

When the user clicks on the first image it is shown correctly, but if any other image is choosen I get this error.

threadid=12: thread exiting with uncaught exception (group=0x40e6f930)

here is the onItemClickListener implementation

class imageClickListener implements OnItemClickListener {

    @Override
    public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
            long arg3) {
        try {
            Bitmap selectedImage = cFindResult.get(arg2);

            Intent i = new Intent(getActivity(), DicomImageActivity.class);

            i.putExtra("Image", selectedImage);

            ShowRadiologyRequestsFragment.this.startActivity(i);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

The cFindResult is an ArrayList<Bitmap>

Is there anyone who can help me know what could be the problem?

Thanks.

Alexander O'Mara
  • 52,993
  • 16
  • 139
  • 151
Firas
  • 1,682
  • 13
  • 25
  • http://stackoverflow.com/questions/23353173/unfortunately-myapp-has-stopped-how-can-i-solve-this – laalto Jul 16 '14 at 07:33

4 Answers4

0

Hey As you not post your Error Log here, we can not identify the problem but as you mentioned above error, These errors occur when something is wrong with the communication between DDMS and the device. They're generally harmless, but you can solve them by restarting the ADB server:

adb kill-server
adb start-server

If you're using the emulator and this doesn't solve the problem, try deleting and recreating the AVD.

Note: Please post your log too.

Manish
  • 1,199
  • 3
  • 10
  • 19
0

Replace the onItemClickListner code with:

Intent i = new Intent(getApplicationContext(), DicomImageActivity.class);
                // passing array index
                i.putExtra("id", arg2);
                startActivity(i);
Raghi
  • 31
  • 1
0

just replace ShowRadiologyRequestsFragment.this by getActivity() like this,

class imageClickListener implements OnItemClickListener {

    @Override
    public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
            long arg3) {
        try {
            Bitmap selectedImage = cFindResult.get(arg2);

            Intent i = new Intent(getActivity(), DicomImageActivity.class);

            i.putExtra("Image", selectedImage);

            getActivity().startActivity(i);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
Akash Moradiya
  • 3,273
  • 1
  • 11
  • 19
0

unfortunately I tried the suggested solutions but none of them worked, but I managed to solve the problem by defining the Bitmap object as a static one, so I can access it from the new activity, I think it was a problem related to the limited size of the objects that can be passed between activities.

Firas
  • 1,682
  • 13
  • 25