F
F
Fotonick2015-07-23 23:51:27
Android
Fotonick, 2015-07-23 23:51:27

What's wrong with passing a string between activities?

I'm trying to send a string from one activity

Intent intent = new Intent(LoginActivity.this, MyPageActivity.class);
Bundle bundle = new Bundle();
bundle.putString("headers", html_value);
intent.putExtras(bundle);
startActivity(intent);

to another
String headers2 = getIntent().getExtras().getString("headers");
TextView outputView = (TextView) findViewById(R.id.responseView);
outputView.setText(headers2);

nothing is caught even though the string being sent has content.
There are a lot of the same questions on the overstack and there is no solution ((

Answer the question

In order to leave comments, you need to log in

3 answer(s)
F
Fotonick, 2015-07-24
@Photonick

It worked like this

Bundle bundle = new Bundle();
bundle.putString("headers", Headers);
Intent intent = new Intent(LoginActivity.this, MyPageActivity.class);
intent.putExtras(bundle);
startActivity(intent);

Bundle bundle=getIntent().getExtras();
String headers2 = bundle.getString("headers");
TextView outputView = (TextView) findViewById(R.id.responseView);
outputView.setText(headers2);

O
one pavel, 2015-07-24
@onepavel

Find the difference from my code?
startActivity(new Intent(getActivity().getApplicationContext(), DetailActivity.class)
.putExtra(DetailActivity.INTENT_PRODUCT, product));
mProduct = getIntent().getParcelableExtra(INTENT_PRODUCT);

E
Emin, 2015-07-24
@Ewintory

That's right, and there will be no solution, because this is the elementary thing that is taught in the first place. Between activities, data is passed through Intent. For example Intent.putExtra(...);
Bundle from another opera.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question