Reputation: 206
The value in string.xml file...
<string name="bangla_history_2ndpoint">SOME VALUE </string>
From this activity i am trying to pass value to another activity ... by using putextra
Intent ptwo=new Intent("com.powergroupbd.victoryday.of.bangladesh.HISTORYDESCRIPTION");
ptwo.putExtra("header", R.string.bangla_history_2ndpoint);
startActivity(ptwo);
Then get the value in this activity ...
But it is not getting the value from the string.xml file...
text_point = getIntent().getStringExtra("header");
Toast.makeText(getApplicationContext(), text_point, Toast.LENGTH_LONG).show();
But it is toasting blank ....
Please give a solution...
Upvotes: 0
Views: 1187
Reputation: 45493
That's because you're trying to retrieve a String
, but what you're passing in as extra is actually the resource identifier of it, an int
. Either put an actual string as extra, or retrieve an int on the receiving end to fix this.
// put:
ptwo.putExtra("header", R.string.bangla_history_2ndpoint);
// get:
int extraResourceId = getIntent().getIntExtra("header");
text_point = getString(extraResourceId);
Or:
// put:
ptwo.putExtra("header", getString(R.string.bangla_history_2ndpoint));
// get:
text_point = getIntent().getStringExtra("header");
Upvotes: 3