首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Android Acitivity生命周期处理错误

问Android Acitivity生命周期处理错误
EN

Stack Overflow用户
提问于 2018-07-20 14:59:11
回答 1查看 42关注 0票数 0

日安,所以我有一个程序,用户将扫描二维码并在SQLite数据库中获得它的值,但在我获得值之前,弹出一个对话框,告诉我“没有找到参与者”。下面是我的代码:

这是我的onStart覆盖。

代码语言:javascript
复制
     @Override
protected void onStart()
{
    super.onStart();
    getparticipantid = tvParticipantID.getText().toString();
    etparticipantidvalue.setText(getparticipantid);
    getParticipantIbeam();
}

这是我的活动,一旦用户扫描二维码,它将从数据库加载数据。

代码语言:javascript
复制
    private void getParticipantIbeam()
{
    SQLiteFunctionUlitity.GameIBeamParticipant memberInfo = SQLiteFunctionUlitity.getparticipantIbeam(getparticipantid, mDbHelper.getSqliteObjectWithReadable());
    if (memberInfo != null)
    {
        tvParticipantName.setText(memberInfo.getParticipantName());
        tvParticipantNation.setText(memberInfo.getParticipant_nationality());
        tvParticipantCategory.setText(memberInfo.getCategory());

        tvWave.setText(memberInfo.getWave_number());
        tvCategory.setText(memberInfo.getCategory());
    }
    else
    {
        Context context = this;
        AlertDialog.Builder builder1 = new AlertDialog.Builder(context);
        builder1.setMessage("No Participant found in the Game.");
        builder1.setCancelable(true);

        builder1.setPositiveButton("Scan Again", new DialogInterface.OnClickListener()
        {
            public void onClick(DialogInterface dialog, int id)
            {
                Intent intent = new Intent(GameiBeamLineTracing.this, ScanGameIbeam.class);
                startActivity(intent);
                finish();
            }
        });
        builder1.setNegativeButton("Close", new DialogInterface.OnClickListener()
        {
            @Override
            public void onClick(DialogInterface dialog, int which)
            {
                onStop();
            }
        });
        AlertDialog alert11 = builder1.create();
        alert11.show();
    }
}

如您所见,我在onStart方法中调用了getParticipantIbeam活动,但是当我调用它时,它读取的是else语句,而不是if语句。

我知道这是一个简单的if else语句和生命周期,但我非常想知道答案。

EN

回答 1

Stack Overflow用户

发布于 2018-07-20 15:36:03

我用过这个库来扫描二维码,它很简单,可能会对你有帮助。

QR Code implementation library for android, Click here (blikoon)

当然,这个库将解决所有与QR Code相关的问题,并且不要忘记实现运行时权限,如照片、图库等。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/51436798

复制
相关文章

相似问题

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