无法销毁主要活动

时间:2013-08-07 12:57:53

标签: android

   08-07 12:51:59.799: E/AndroidRuntime(1240): java.lang.RuntimeException: Unable to             
   destroy activity {com.example.cap_im/com.example.cap_im.MainActivity}:        
   java.lang.NullPointerException

在我的Android应用程序中,我有两个活动,称为Splash屏幕和主要活动。当我运行应用程序时它工作正常。但是当我点击后退按钮。我得到以下错误。在我的破坏方法我关闭我的光标。你可以帮助我。

         public static String convertImageUriToFile(Uri imageUri, Activity activity) {


    int imageID = 0;

    try {

        /*********** Which columns values want to get *******/
        String[] proj = { MediaStore.Images.Media.DATA,
                MediaStore.Images.Media._ID,
                MediaStore.Images.Thumbnails._ID,
                MediaStore.Images.ImageColumns.ORIENTATION };

        cursor = activity.getContentResolver().query(imageUri, proj, null,
                null, null);

        // Get Query Data

        int columnIndex = cursor
                .getColumnIndexOrThrow(MediaStore.Images.Media._ID);
        int file_ColumnIndex = cursor
                .getColumnIndexOrThrow(MediaStore.Images.Media.DATA);

        // int orientation_ColumnIndex = cursor.
        // getColumnIndexOrThrow(MediaStore.Images.ImageColumns.ORIENTATION);

        int size = cursor.getCount();

        /******* If size is 0, there are no images on the SD Card. *****/

        if (size == 0) {

            // imageDetails.setText("No Image");
        } else {

            if (cursor.moveToFirst()) {

                imageID = cursor.getInt(columnIndex);
                delete_image_id = imageID;

                Path = cursor.getString(file_ColumnIndex);


            }

        }

    } finally {
        if (cursor != null) {

        }
    }

0 个答案:

没有答案