因此,昨晚我以爲我有我的應用程序工作,但是,今天早上gremlins已入侵,現在已經使我的應用程序無法正常工作的功能。照片不在圖像視圖中顯示android
基本上,一個按鈕允許用戶拍照,並在Imageview中顯示該照片,然後將該圖像附加到電子郵件中。它讓我拍攝照片,它仍然作爲附件呈現,但圖像視圖中的預覽完全是空的。
任何人都可以看到發生了什麼?
Hoon_Image = (ImageView) findViewById(R.id.CapturedImage);
button_take_photo = (Button)findViewById(R.id.btn_take_photo);
button_take_photo.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v) {
try {
f = createImageFile();
Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
cameraIntent.putExtra(android.provider.MediaStore.EXTRA_OUTPUT, Uri.fromFile(f));
startActivityForResult(cameraIntent, CAMERA_REQUEST);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
});
public File getAlbumDir()
{
File storageDir = new File(
Environment.getExternalStoragePublicDirectory(
Environment.DIRECTORY_PICTURES
),
"BAC/"
);
// Create directories if needed
if (!storageDir.exists()) {
storageDir.mkdirs();
}
return storageDir;
}
private File createImageFile() throws IOException {
// Create an image file name
String imageFileName =getAlbumDir().toString() +"/image.jpg";
File image = new File(imageFileName);
return image;
}
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (resultCode == RESULT_OK) {
if(requestCode == CAMERA_REQUEST){
Bitmap photo = BitmapFactory.decodeFile(f.getAbsolutePath());
Hoon_Image.setImageBitmap(photo);
}
}
if (resultCode == RESULT_OK) {
if (requestCode == SELECT_PICTURE) {
Uri selectedImageUri = data.getData();
//OI FILE Manager
filemanagerstring = selectedImageUri.getPath();
//MEDIA GALLERY
selectedImagePath = getPath(selectedImageUri);
//DEBUG PURPOSE - you can delete this if you want
if(selectedImagePath!=null)
System.out.println(selectedImagePath);
else System.out.println("selectedImagePath is null");
if(filemanagerstring!=null)
System.out.println(filemanagerstring);
else System.out.println("filemanagerstring is null");
//NOW WE HAVE OUR WANTED STRING
if(selectedImagePath!=null)
System.out.println("selectedImagePath is the right one for you!");
else
System.out.println("filemanagerstring is the right one for you!");
}
Bitmap photo = BitmapFactory.decodeFile(selectedImagePath);
Hoon_Image.setImageBitmap(photo);
Photo_Selected = 1;
}
}
這並不完全回答我的問題雖然。 – scb998 2014-10-22 01:41:00
但ImageView已經顯示圖像? – avinea28 2014-10-22 01:44:45
我上面的代碼在前一天晚上工作,今天早上它不是。如果我能避免它,我不想重新編寫我的應用程序。 – scb998 2014-10-22 01:50:48