IM建立一些應用程序調用攝像頭的活動..拍攝照片並將其發送到Web服務器
我只是從我的應用程序拍照並將其發送到網絡服務器..
但我不能讓我的圖片的路徑..
,我都會讓NullException錯誤時,試圖讓圖像路徑..
呼叫相機活動時,這裏是我的代碼:
Intent camera = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
this.startActivityForResult(camera, PICTURE_RESULT);
,這是對活動結果代碼:
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == PICTURE_RESULT){
if (resultCode == Activity.RESULT_OK) {
takePicture(data);
} else if (resultCode == Activity.RESULT_CANCELED) {
}
}
}
protected void takePicture(Intent data) {
Bundle b = data.getExtras();
pic = (Bitmap) b.get("data");
if (pic != null) {
imagePicture.setImageBitmap(pic);
}
}
是有什麼錯我的代碼?
謝謝
您已經添加了攝像頭允許您的清單,是嗎? – Otra
是的,我已經添加了權限 – pensilhijau