Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Let me answer it myself:) I managed to get it working. Im still discovering Android. First of all the code above will never work. Nonetheless its still a hell of a job to work with camera ... and test it. I cant get the intent working in the emulator for 2.2, for 2.1 it works. But the code works for 2.2 and 2.1 on the device. Another weird thing that i discovered is that when you attach the debugger to your device its not possible to use MediaStore.Images.Media.EXTERNAL_CONTENT_URI. It throws an error that the external storage doesnt exist. It has to do with the USB connection. Anyway, the code used to intent the camera:</p> <pre><code> String fileName = System.currentTimeMillis() + ".jpg"; ContentValues values = new ContentValues(); values.put(MediaStore.Images.Media.TITLE, fileName); values.put(MediaStore.Images.Media.DESCRIPTION, "Image capture by camera"); values.put(MediaStore.Images.Media.MIME_TYPE, "image/jpeg"); try { imageUri = getContentResolver().insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values); } catch (Exception e) { Log.e(TAG, "", e); } Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); intent.putExtra(MediaStore.EXTRA_OUTPUT, imageUri); ctx.startActivityForResult(intent, REQUEST_CODE_PHOTO); </code></pre> <p>Pretty standard, i added the try catch to avoid that the app crashed when i attach a debugger to my device. If you pass null for MediaStore.EXTRA_OUTPUT the camera will show a message that the sdcard could not be found. Which is better then crashing.</p> <p>After you take the picture the camera will return to your current activity and you can use the image which will be stored in the imageUri variable.</p> <p>In the emulator for 2.2 the error “FATAL EXCEPTION: GLThread 11” is still thrown when i try to use the camera, which is annoying. Does anyone has a solution to get it working on the emulator?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload