0

我使用了很多代码并且都在 4.0 上工作,但是果冻豆操作系统不支持任何代码

 try
                     {
        Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);

        startActivityForResult(cameraIntent, 1);        
                     }
                  catch(ActivityNotFoundException anfe){
                    //display an error message
    //                  String errorMessage = "Whoops - your device doesn't support capturing images!";
                     Toast toast= Toast.makeText(getApplicationContext(), "Whoops - your device doesn't support capturing images!", Toast.LENGTH_SHORT);  
                     toast.setGravity(Gravity.CENTER, 0, 0);
                     toast.show();

                }
4

2 回答 2

3

在您的 onCreate 或单击按钮时添加此代码

Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE); 
startActivityForResult(cameraIntent, CAMERA_REQUEST);



private void startActivityForResult(Intent data, int requestCode) {
    // TODO Auto-generated method stub
 if (requestCode == CAMERA_REQUEST) {  

     Bitmap photo = (Bitmap) data.getExtras().get("data"); 
     yourActivity.pictureImg.setImageBitmap(photo);
 }  

 if (requestCode == SELECT_PICTURE) {  
     Uri selectedImageUri = data.getData();
     //OI FILE Manager
     filemanagerstring = selectedImageUri.getPath();
     //MEDIA GALLERY
     selectedImagePath = getPath(selectedImageUri); 
     photo = BitmapFactory.decodeFile(selectedImagePath);
     yourActivity.pictureImg.setImageBitmap(photo);

 }  
}
于 2013-04-09T10:35:45.333 回答
0

我想你忘了在清单文件中添加权限我不知道 Os 但在 android 中它就像它

<uses-permission android:name="android.permission.CAMERA"/>
于 2013-04-09T10:16:21.597 回答