0

Please can you help out with this: I pass a bundle via an intent and need to display it on a textview,but I am unable to get any display on my textview. The code is :

Intent part of the code:

if(result != null)
{
    Intent tokenIntent = new Intent(mContext, tokenActivity.class);
    Bundle bundle = new Bundle();
    bundle.putString("responsedata",result);

    tokenIntent.putExtras(bundle);
    startActivity(tokenIntent);
}

Activity receiving the intent:

TextView response;
Bundle bundle;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main2);

    response=(TextView)findViewById(R.id.texter);
    bundle = getIntent().getExtras();
    response.setText(bundle.getString("responsedata"));
    //  sampletext.setText(result);
}
4

1 回答 1

0

在你的代码意图部分,使用这个:

tokenIntent.putExtra("responsedata",result);

并删除这部分:

Bundle bundle = new Bundle();
bundle.putString("responsedata",result);
tokenIntent.putExtras(bundle);

让我知道是否可以。

于 2013-08-21T14:51:57.077 回答