1
我已經制作了自己的應用程序,有一個菜單,並且在一個活動中iam試圖獲取qrcode的結果。 我需要得到IntentResult,但是如何?我在哪裏獲得onActivityResult的工作? 這是一個有趣的混亂,這是通過意圖。Zxing:活動獲得結果
我該如何實現一個函數來將文本轉換爲字符串?
真的很感激。 RMC
活動:
public class Authentication extends Activity {
TextView showResults;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
//Load file xml
setContentView(R.layout.authentication);
//To create start button
Button scan = (Button) findViewById(R.id.btnStartAuth);
scan.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
IntentIntegrator integrator = new IntentIntegrator(Authentication.this);
integrator.initiateScan();
}
});
//HERE I NEED TO GET THE VALUE OF THE QR CODE WITH MY ONACTIVITYRESULT
// BUT WHERE I GET THE
//PROTOTYPE VALUES?
} //end_of_onCreate
// functions
public void getResult(int requestCode, int resultCode, Intent intent) {
if (requestCode == 0) {
if (resultCode == RESULT_OK) {
String contents = intent.getStringExtra("SCAN_RESULT");
String format = intent.getStringExtra("SCAN_RESULT_FORMAT");
EditText showResults = (EditText) findViewById(R.id.txtviewResultados);
showResults.setText(contents);
} else if (resultCode == RESULT_CANCELED) {
// Every time I receive this code
showResults.setText("Error reading: result null");
}
}
}
}//end_of_activity
`