M
M
Mikhail2017-02-12 14:42:59
Android
Mikhail, 2017-02-12 14:42:59

The Bundle passes the string data, but the class does not accept it. What to do?

Essence of the question: I pass several values ​​of different types to another class
By type

toResults.putExtra("text", s);
 toResults.putExtra("xp", xp);
 toResults.putExtra("isfirst", true);

In the Results class, I process the receipt of values ​​​​through the bundle, but only the values ​​\u200b\u200bof numbers are read, instead of the transmitted string, it writes null.
I looked through the debugger, the line is being transmitted. Key and there and there is correct, but does not read.
I accept it like this:
final Bundle bundle = getIntent().getExtras();
        if (bundle!=null){
            s = bundle.getString("text");
            ...
        }

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Mikhail, 2017-02-12
@MTankov

Resolved by restarting the studio - magic)

D
Dmitry Serkov, 2017-02-12
@Hutaab

What if you try it?

Intent intent = getIntent();
        String message = intent.getStringExtra("text");

Yes, and see what you send. Maybe null and pass.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question