i'm very new to posting questions on this site as well as programming. Forgive me if i miss out on something or a wrong format and such. Putting my hands on android for a project, a restaurant order system. Using android eclipse to do it. I have been successful in making an app that scans QR and displays the results.
When you press scan, it opens the camera and scans a QR and displays the results under "Orders". What i haven't been able to figure out is how can i make it so that everytime i scan, it just adds a new result under the orders? Right now, everytime i scan, it replaces the current result with the new one. I want it to keep adding the results into the order.
This the current coding i have for the Main Activity
public class MainActivity extends Activity {
TextView tvResult;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
tvResult = (TextView) findViewById(R.id.tvResult);
Button scanBtn = (Button) findViewById(R.id.btnScan);
add:
scanBtn.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
try {
Intent intent = new Intent(
"com.google.zxing.client.android.SCAN");
intent.putExtra("SCAN_MODE", "QR_CODE_MODE,PRODUCT_MODE");
startActivityForResult(intent, 0);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
Toast.makeText(getApplicationContext(), "ERROR:" + e, 1).show();
}
}
});
}
public void onActivityResult(int requestCode, int resultCode, Intent intent) {
if (requestCode == 0) {
if (resultCode == RESULT_OK) {
tvResult.setText(intent.getStringExtra("SCAN_RESULT"));
} else if (resultCode == RESULT_CANCELED) {
tvResult.setText("Scan cancelled.");
}
}
}
A second question, after displaying the results which after scanning will display "51 Cheese Salami $6.90" for one result as example. The solution to the first question would allow it to be displayed as such
51 Cheese Salami $6.90
52 Charcoal Onion Beef $7.50
53 Salami Panini $6.30
and so on;
I have to send the results to a web service. What would be the best course of action? How would i be able to separate the results into specifics like ID, Name, Price. Parsing it? Adding it into a database first? Is it possible to not involve the use of database? Please correct my question if it doesn't make sense.