28 |
private Button scanBtn; |
private Button scanBtn; |
29 |
private TextView formatTxt, contentTxt; |
private TextView formatTxt, contentTxt; |
30 |
|
|
31 |
|
//ved rotate bliver activity'en genstartet - så enten skal variablerne gøres static/gemmes på anden vis eller også skal man låse for rotation |
32 |
|
static String scanContent = ""; |
33 |
|
static String scanFormat = ""; |
34 |
|
|
35 |
|
|
36 |
|
|
37 |
@Override |
@Override |
38 |
protected void onCreate(Bundle savedInstanceState) { |
protected void onCreate(Bundle savedInstanceState) { |
39 |
super.onCreate(savedInstanceState); |
super.onCreate(savedInstanceState); |
61 |
|
|
62 |
} |
} |
63 |
|
|
64 |
|
@Override |
65 |
|
protected void onStart() { |
66 |
|
super.onStart(); |
67 |
|
updateLabels(); |
68 |
|
} |
69 |
|
|
70 |
public void onActivityResult(int requestCode, int resultCode, Intent intent) { |
public void onActivityResult(int requestCode, int resultCode, Intent intent) { |
71 |
IntentResult scanningResult = IntentIntegrator.parseActivityResult(requestCode, resultCode, intent); |
IntentResult scanningResult = IntentIntegrator.parseActivityResult(requestCode, resultCode, intent); |
72 |
|
|
73 |
if (scanningResult != null) { |
if (scanningResult != null) { |
74 |
String scanContent = scanningResult.getContents(); |
scanContent = scanningResult.getContents(); |
75 |
String scanFormat = scanningResult.getFormatName(); |
scanFormat = scanningResult.getFormatName(); |
76 |
|
|
77 |
formatTxt.setText("FORMAT: " + scanFormat); |
updateLabels(); |
|
contentTxt.setText("CONTENT: " + scanContent); |
|
78 |
} |
} |
79 |
else{ |
else{ |
80 |
Toast toast = Toast.makeText(getApplicationContext(), "No scan data received!", Toast.LENGTH_SHORT); |
Toast toast = Toast.makeText(getApplicationContext(), "No scan data received!", Toast.LENGTH_SHORT); |
82 |
} |
} |
83 |
} |
} |
84 |
|
|
85 |
|
private void updateLabels() { |
86 |
|
formatTxt.setText("FORMAT: " + scanFormat); |
87 |
|
contentTxt.setText("CONTENT: " + scanContent); |
88 |
|
} |
89 |
|
|
90 |
@Override |
@Override |
91 |
public boolean onCreateOptionsMenu(Menu menu) { |
public boolean onCreateOptionsMenu(Menu menu) { |
92 |
// Inflate the menu; this adds items to the action bar if it is present. |
// Inflate the menu; this adds items to the action bar if it is present. |