0

in the name of god

Hi,

i use this cod for take picture :

 private void takePicture() {

            Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);

            try {
                Uri mImageCaptureUri = null;
                String state = Environment.getExternalStorageState();
                if (Environment.MEDIA_MOUNTED.equals(state)) {
                    mImageCaptureUri = Uri.fromFile(mFileTemp);
                }
                else {
                    /*
                     * The solution is taken from here: http://stackoverflow.com/questions/10042695/how-to-get-camera-result-as-a-uri-in-data-folder
                     */
                    mImageCaptureUri = InternalStorageContentProvider.CONTENT_URI;
                }   
                intent.putExtra(android.provider.MediaStore.EXTRA_OUTPUT, mImageCaptureUri);
                intent.putExtra("return-data", true);
                startActivityForResult(intent, REQUEST_CODE_TAKE_PICTURE);
            } catch (ActivityNotFoundException e) {

                Log.d(DBAdapter.TAG, "cannot take picture", e);
            }
        }

this is good in some device but in some other devise this not work and data in onActivityResult i null , i am realy do not know what must doing . i very searched in github and stackoverflow but still not found any answers :(

abbasalim
  • 3,118
  • 2
  • 23
  • 45
  • can u show the log cat? – Ramz Aug 28 '14 at 17:33
  • no , because no problem in emulator and it device is unknown in eclipse :( , but i know that problem is with out of memory – abbasalim Aug 28 '14 at 17:41
  • 1
    "this not work" is too generic to address; **null** data in `onActivityResult()` is normal on some devices; at any rate, data only gives you a thumbnail bitmap of the captured image, which bitmap can be used in a list or grid view, but cannot fill the screen anyways. – Alex Cohn Sep 01 '14 at 15:43
  • thanks :) i found a sample that work – abbasalim Sep 01 '14 at 16:33

2 Answers2

0

Please try this.....

 private static final int cameraRequest = 10000; 

 ..........On Button Click................

 Intent cameraClickIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE); 
            startActivityForResult(cameraClickIntent, cameraRequest); 
..........................................


//////////On activity result////////////////////

 protected void onActivityResult(int requestCode, int resultCode, Intent data) {  
    if (requestCode == cameraRequest && resultCode == RESULT_OK) {  
        Bitmap photo = (Bitmap) data.getExtras().get("data"); 
        imageView.setImageBitmap(photo);
    }  
}

dont forget to add these line to manisfest file

<uses-feature android:name="android.hardware.camera"></uses-feature> 
<uses-feature android:name="android.hardware.camera" android:required="false"></uses-feature>

Hope this will help you....

Ramz
  • 7,116
  • 6
  • 63
  • 88
0

this source worked successfully https://github.com/dustookk/AndroidImagePicker

abbasalim
  • 3,118
  • 2
  • 23
  • 45