How can I apply the QR Code scanner to my Webview application in android studio and then put the QRCode in the Google search engine, for example, the application now puts the QR Code in the result box. Please help me.
public class MainActivity extends AppCompatActivity {
Button btn_scan;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
btn_scan = findViewById(R.id.btn_scan);
btn_scan.setOnClickListener(v -> {
scanCode();
});
}
private void scanCode() {
ScanOptions options = new ScanOptions();
options.setPrompt("Volume up to flash on");
options.setBeepEnabled(true);
options.setOrientationLocked(true);
options.setCaptureActivity(CaptureAct.class);
barlaucher.launch(options);
}
ActivityResultLauncher<ScanOptions> barlaucher = registerForActivityResult(new ScanContract(), result -> {
if (result.getContents() != null) {
AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
builder.setTitle("Result");
builder.setMessage(result.getContents());
builder.setPositiveButton("ok", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
dialogInterface.dismiss();
}
}).show();
}
});
}
It might help us to approach this problem in phases.
Personally, I'd possibly just load the QR Code stuff directly so it gets handled fairly proper by native WebView framework. This will mitigate well for general situations. But any time we allow end-users to interact with DOM like that we are inviting exponential JS havoc . To be honest this would be a rather alarming feature to have on an official app.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.