坚野software_awen
2017-04-23 17:10
采纳率: 100%
浏览 1.6k

紧急求助各位前辈,Android Zxing onActivityResult 没调用到底什么原因

没有任何错误信息,只是textView没有得到值,具体代码如下:
public class MainActivity extends AppCompatActivity implements View.OnClickListener {

private Button btr;
private TextView tv;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    initView();
    listen();
}


private void listen() {
    btr.setOnClickListener(this);
    tv.setOnClickListener(this);
}

private void initView() {
    btr = (Button) findViewById(R.id.button);
    tv = (TextView) findViewById(R.id.tv);
}

@Override
public void onClick(View view) {
    switch (view.getId()) {
        case R.id.button:
            startActivityForResult(new Intent(MainActivity.this, CaptureActivity.class),0);
            break;
    }
}

public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
        Bundle bundle = data.getExtras();
        String theresult = bundle.getString("result");
        tv.setText(theresult);
}

}

2条回答 默认 最新

相关推荐 更多相似问题