我从Android应用程序扫描Qr代码时遇到问题。我正在使用库扫描Qr代码,它从旧版本2.3到新版本4.3工作,但我无法扫描最新的Android 4.4版本的qr代码(读取),我没有得到任何异常?我不知道究竟是什么问题以及android 4.4版本的最新zxing库是什么?请告诉我什么是更好的解决方案。 感谢您的帮助..请帮助
@Override
public void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_qr_screen_layout);
Intent intent = new Intent("com.google.zxing.client.android.SCAN");
intent.putExtra("SCAN_MODE", "QR_CODE_MODE");
startActivityForResult(intent, 0);
}
public void onActivityResult(int requestCode, int resultCode, Intent intent) {
if (requestCode == 0) {
if (resultCode == RESULT_OK) {
// Handle successful scan
QRcontents = intent.getStringExtra("SCAN_RESULT");
int QRcontentslength =QRcontents.length();
hidecode = "StudentUserId";
code = QRcontents.substring(0,13);
if(code.trim().equals(hidecode.trim())){
QRcontents = QRcontents.substring(14, QRcontentslength);
// Goto Profile
gotoNextScreen();
}
else{
Toast toast = Toast.makeText(this, "Invalid QR Code Image", Toast.LENGTH_LONG);
toast.setGravity(Gravity.TOP, 25, 400);
toast.setDuration(10000);
toast.show();
}
}
else if (resultCode == RESULT_CANCELED) {
// Handle cancel
Toast toast = Toast.makeText(this, "Scan is Cancelled!", Toast.LENGTH_LONG);
toast.setGravity(Gravity.TOP, 25, 400);
toast.show();
Intent intent1 = new Intent(getApplicationContext(),DashBoardActivity.class);
intent1.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent1);
finish();
}
}
我的Android应用版本:android:minSdkVersion =“10”,android:targetSdkVersion =“18” 我正在使用 zxing 2.3.0 lib
感谢。