Estoy adaptando una aplicacion para leer codigos qr que estaba en kotlin a java. Solo me queda un error en esta linea:
intentIntegrator.setDesiredBarcodeFormats((Collection)CollectionsKt.listOf("QR_CODE"));
Me lanza este error: "Cannot resolve symbol 'CollectionsKt'". No se como adaptar eso a java. Parece ser la lista de tipos de codigos qr que admite. El programa completo es este:
public class MainActivity extends AppCompatActivity {
TextView textView;
ImageButton qrButton;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
textView = findViewById(R.id.textView);
qrButton= findViewById(R.id.qr_button);
qrButton.setOnClickListener(new View.OnClickListener() {
public final void onClick(View it) {
IntentIntegrator intentIntegrator = new IntentIntegrator(MainActivity.this);
intentIntegrator.setDesiredBarcodeFormats((Collection)CollectionsKt.listOf("QR_CODE"));
//intentIntegrator.setDesiredBarcodeFormats(IntentIntegrator.ONE_D_CODE_TYPES);
intentIntegrator.initiateScan();
}
});
}
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
super.onActivityResult(requestCode, resultCode, data);
final IntentResult result = IntentIntegrator.parseActivityResult(resultCode, data);
if (result != null) {
(new AlertDialog.Builder((Context)this)).setMessage((CharSequence)("Would you like to go to " + result.getContents() + '?')).setPositiveButton((CharSequence)"Yes", (android.content.DialogInterface.OnClickListener)(new android.content.DialogInterface.OnClickListener() {
public final void onClick(DialogInterface dialogInterface, int i) {
Intent intent = new Intent("android.intent.action.WEB_SEARCH");
intent.putExtra("query", result.getContents());
MainActivity.this.startActivity(intent);
}
})).setNegativeButton((CharSequence)"No", (android.content.DialogInterface.OnClickListener)null).create().show();
}
//Toast.makeText(this, result.toString(), Toast.LENGTH_LONG).show();
}
}