MainActivity.class:
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
IntentResult result = IntentIntegrator.parseActivityResult(requestCode, resultCode, data);
if (result != null) {
if (result.getContents() == null) {
Toast.makeText(this, "Result Not Found", Toast.LENGTH_LONG).show();
} else {
try {
//converting the data to json
JSONObject obj = new JSONObject(result.getContents());
Toast.makeText(this, obj.getString("id"), Toast.LENGTH_LONG).show();
} catch (JSONException e) {
e.printStackTrace();available on the qrcode
Toast.makeText(this, result.getContents(), Toast.LENGTH_LONG).show();
}
}
} else {
super.onActivityResult(requestCode, resultCode, data);
}
}
扫描QR码后,如何将数据导入MySQL数据库?
答案 0 :(得分:0)
您可以这样做
IntentResult result = IntentIntegrator.parseActivityResult(requestCode, resultCode, data);
if (result != null) {
//if qrcode has nothing in it
if (result.getContents() == null) {
Toast.makeText(this, " Not Found", Toast.LENGTH_LONG).show();
} else {
try {
JSONObject obj = new JSONObject(result.getContents());
// Toast.makeText(this,"results"+ result.getContents(), Toast.LENGTH_LONG).show();
} catch (JSONException e) {
e.printStackTrace();
// Toast.makeText(this,"results again : "+ result.getContents(), Toast.LENGTH_LONG).show();
staffLoginQRCODE(result.getContents());
}
}
} else {
super.onActivityResult(requestCode, resultCode, data);
}
private void staffLoginQRCODE(final String check_result) {
hit your api for resonse }