我在我的應用程序中調用默認圖庫應用程序來選擇任何照片。以下是我從代碼庫中獲取所選圖像路徑的代碼。除少數照片外,所有照片都能正常工作。當我選擇PICASA上傳的任何照片時,應用程序正在強制關閉。請幫幫我。無法從Android中的圖庫中選擇少量照片
內onActivityResult()....
Uri selectedImage = data.getData();
String[] filePathColumn = { MediaStore.Images.Media.DATA };
Cursor cursor = getContentResolver().query(selectedImage, filePathColumn, null, null, null);
cursor.moveToFirst();
int columnIndex = cursor.getColumnIndex(filePathColumn[0]);
String selectedPhotoPath = cursor.getString(columnIndex).trim(); <<--- NullPointerException here
cursor.close();
bitmap = BitmapFactory.decodeFile(selectedPhotoPath);
......
LogCat告訴你什麼? – 2012-07-09 13:08:46
NullpointerException – Santhosh 2012-07-09 13:09:23
它在哪一行給你一個NPE?是data.getData()!= null? – 2012-07-09 13:11:36