我已经制作了自己的应用程序,带有菜单,并且在一项活动中我试图获得 qrcode 的结果。我需要得到 IntentResult 但如何?我在哪里得到 onActivityResult 工作?它有点混乱,这是通过意图。
如何实现将文本转换为字符串的函数?
真心感谢。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
`