1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
| @Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_create_customer);
Button scanbutton = (Button) findViewById(R.id.scan_button);
scanbutton.setOnClickListener(this);
}
@Override
public void onClick(View v) {
if(v.getId() == R.id.scan_button){
new IntentIntegrator(this).initiateScan();
}
}
public void onActivityResult(int requestCode, int resultCode, Intent intent) {
IntentResult scanningResult = IntentIntegrator.parseActivityResult(requestCode, resultCode, intent);
if (scanningResult !=null) {
String scanContent = scanningResult.getContents();
String scanFormat = scanningResult.getFormatName();
EditText editTextCreateCustomerCardNumber = (EditText) findViewById(R.id.editTextCreateCustomerCardNumber);
editTextCreateCustomerCardNumber.setText(editTextCreateCustomerCardNumber);
}else {
Toast toast = Toast.makeText(getApplicationContext(),"Aucune carte n'a été scannée ", Toast.LENGTH_SHORT);
toast.show();
}
}
@Override
public boolean onOptionItemSelected(MenuItem item) {
int id = item.getItemId();
if (id == R.id.action_settings) {
return true;
}
return super.onOptionItemSelected(item);
} |
Partager