You will have to carry with me, I am very new to Android, and my Java skills are "rusty" at best.
I was very happy to get a barcode scan bit that works with very little effort, but the camera side is not very simple.
I have a core Activity class that calls a barcode when it starts;
@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");
}
});
}
We are still working, and I correctly process the intention, as shown:
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"))
{
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;
}
}
}
I have configured callbacks (they currently have no code), but after scanning the barcode, the device simply displays a black screen. Then I have to restart the device after debugging the application, because the camera is no longer accessible (I suspect that I have not cleared my link, so the camera is locked for my application)
- , SD- ( SD- - :
filepath = filepath + UUID.randomUUID().toString() + ".jpg";
, .
( - - T-Mobile ( , Huawei), , , , , , .)
, .