Note that there are some explanatory texts on larger screens.

plurals
  1. POSaving pictures from the camera in Android
    primarykey
    data
    text
    <p>You'll have to bear with me, I'm very new to Android and my Java skills are "rusty" at best.</p> <p>I was pretty excited to get the barcode scan bit working with very little effort indeed, but the camera side of things really isn't proving as easy.</p> <p>I've got a main Activity class that calls for a barcode when it starts up;</p> <pre><code>/** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); Button cameraButton = (Button) findViewById(R.id.cameraButton); cameraButton.setOnClickListener( new OnClickListener(){ public void onClick(View v ){ IntentIntegrator.initiateScan(MakroDroidActivity.this, "Please scan order barcode", "Please scan a valid order barcode", "Yes", "No"); } }); } </code></pre> <p>Working so far and I correctly handle the intent as shown:</p> <pre><code>protected void onActivityResult(int requestCode, int resultCode, Intent data) { switch(requestCode) { case IntentIntegrator.REQUEST_CODE: { if (resultCode != RESULT_CANCELED) { IntentResult scanResult = IntentIntegrator.parseActivityResult(requestCode, resultCode, data); if (scanResult != null) { String upc = scanResult.getContents(); if (upc.startsWith("ORD")) { //we have a valid order barcode Camera cam = Camera.open(); cam.takePicture(shutterCallback, rawCallback, jpegCallback); } else { IntentIntegrator.initiateScan(MakroDroidActivity.this, "Please scan again", "Please scan a valid order barcode", "Yes", "No"); } } } break; } } } </code></pre> <p>I have the call backs set up (currently with no code in them) but after the barcode is scanned, the device just displays a black screen. I then need to restart the device after debugging the app because the camera is no longer available (I suspect that I have not cleaned up my reference so the camera is locked to my app)</p> <p>Can somebody explain to me how I go about using the camera and saving the output to the SD card (I'm planning on using a specific folder on the SD card with something like: </p> <pre><code>filepath = filepath + UUID.randomUUID().toString() + ".jpg"; </code></pre> <p>to save a new, non-conflicting filename to the folder.</p> <p>(Device is a T-Mobile pulse mini (Huawei manufactured I believe) and I have seen other people say there are driver issues with the camera but I am more inclined to believe it is a lack of my understanding rather than a hardware issue.)</p> <p>Thanks in advance for any assistance you can give on this.</p>
    singulars
    1. This table or related slice is empty.
    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.
 

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