java.lang.RuntimeException:将结果传递给activity {}失败:java.lang.NullPointerException

时间:2012-11-29 10:08:40

标签: android android-intent camera

我正在尝试使用相机拍照后更改Button属性。

@Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        if (resultCode != RESULT_OK) return;

        Bitmap bitmap = utilities.decodeFile(path, 300);
        imgPicHolder.setImageBitmap(bitmap);
        //The pic is changing on the previous Activity, this works fine



        Button button = (Button)findViewById(R.id.btnChange);
         button.setText("NewText");
        //Here is the problem, when trying to change the button property from the previous      activity before taking the picture..



}

1 个答案:

答案 0 :(得分:1)

我要做的是将StringActivity2传递到Activity1再传递给Intent.putExtra(),然后在Activity1中使用getIntent().getStringExtra()来回复此问题string然后将其设置为Button的{​​{1}}

中的Activity1文字