i made an android app using zxing library for barcode scan. barcode reader start when i tap on button, this is the code:
//scan
mScanBtn = (Button)findViewById(R.id.scan);
mScanBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
try {
Intent intent = new Intent(
"com.google.zxing.client.android.SCAN");
intent.setPackage("com.app.myapp");
intent.putExtra("SCAN_MODE", "ONE_D_MODE");
startActivityForResult(intent, 0);
} catch (Exception e) {
e.printStackTrace();
}
}
});
This code works fine and barcode scanner start. But i want to start also ledflashlight (if present) when barcode reader start. There is a way to start flashlight when zxing library start?
No, you can't force the flashlight on when you start the app. The idea is that the user is in the best position to control whether it's on or not. I wouldn't want an app turning on a bright light in the wrong situation.