首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >ZXingScannerView无法在小米设备上运行

ZXingScannerView无法在小米设备上运行
EN

Stack Overflow用户
提问于 2020-06-25 02:33:05
回答 1查看 60关注 0票数 0

听着,我还有一个问题。我正在使用Android Tudio中的ZXing扫描仪。它可以工作,但对于小米,它只能在qr摄像头打开的情况下工作。

这是我的代码:

代码语言:javascript
复制
@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访问:

代码语言:javascript
复制
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);
EN

回答 1

Stack Overflow用户

发布于 2020-11-13 04:06:23

对于只有小米设备有这个问题的人,我发现虽然ZXing在调试时不能工作,但当你生成一个APK,移动到设备上并手动安装它时,扫描器可以按预期工作。

看起来像是与调试环境相关的问题,在发布应用程序时不应该出现。

来源:

已在虚拟设备和虚拟摄像头上调试

  • :S10+上的Worked
  • Debugged : Redmi上的Worked
  • Debugged备注8T: to
  • 已在Redmi上调试注意5: to
  • 生成的APK,已移动到8T,已安装(更新了旧的调试apk):有效的
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/62561857

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档