A
A
artshelom2017-10-03 14:43:21
Android
artshelom, 2017-10-03 14:43:21

How to take value in AppCompatActivity from Intenta??

How to take value in AppCompatActivity from Intenta?
I run it like this:

Intent intent = new Intent(getActivity(), GG.class);
Bundle bundle = new Bundle();
bundle.putString("url", questionObject.getHref());
intent.putExtras(bundle);
startActivity(intent);

And I take it like this:
String url = null;
        Bundle bundle = savedInstanceState;
        if (bundle!=null) url = bundle.getString("url", null);

And when I want to take the value of the parameter, it gives me null, what's wrong??

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrey Myvrenik, 2017-10-03
@artshelom

Bundle extras = getIntent().getExtras();
if (extras != null) {
    url = extras.getString("url", null);
}

savedInstanceState is used to restore the state of an Activity after a configuration change, such as a screen rotation.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question