听着,我还有一个问题。我正在使用Android Tudio中的ZXing扫描仪。它可以工作,但对于小米,它只能在qr摄像头打开的情况下工作。
这是我的代码:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main_q_r_scann);
ViewGroup contentFrame = (ViewGroup) findViewById(R.id.content_frame);
mScannerView = new ZXingScannerView(this);
mScannerView.setAutoFocus(true);
contentFrame.addView(mScannerView);
Bundle extras = getIntent().getExtras();
if(extras !=null) {
disconnect = extras.getString("disconnect");
}
notifm = (NotificationManager)getApplicationContext().getSystemService(Context.NOTIFICATION_SERVICE);
notifm.cancelAll();
preferences = PreferenceManager.getDefaultSharedPreferences(this);
if(latitud == null){
latitud = preferences.getString("coorlat","");
longitud = preferences.getString("coorlong","");
}
}从服务后台的Intent访问:
Intent content = new Intent(getApplicationContext(),MainQRScann.class);
content.putExtra("disconnect", ident);
content.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK |Intent.FLAG_ACTIVITY_CLEAR_TASK);
activityF.startActivity(content);
new android.os.Handler().postDelayed(
new Runnable() {
public void run() {
diafinal.dismiss();
}
}, 650);发布于 2020-11-13 04:06:23
对于只有小米设备有这个问题的人,我发现虽然ZXing在调试时不能工作,但当你生成一个APK,移动到设备上并手动安装它时,扫描器可以按预期工作。
看起来像是与调试环境相关的问题,在发布应用程序时不应该出现。
来源:
已在虚拟设备和虚拟摄像头上调试
https://stackoverflow.com/questions/62561857
复制相似问题