Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android cannot get boolean value from bundle

In my GcmListenerService I am getting this bundle data:

Bundle[{gcm.notification.e=1, gcm.notification.title=SomeApp, proceed=true, gcm.notification.body=Some text, message=Some message, collapse_key=example.com.SomeApp}]

I am can get the message by

bundle.getString("message");

But i cannot get the proceed boolean value int the bundle data. I used:

bundle.getBoolean("proceed",false);

this is always giving false, even when the value is true in the bundle data. It is so simple, i don't know what i am missing. Thanks.

like image 344
ArJ Avatar asked Jan 20 '26 08:01

ArJ


1 Answers

Even though the value of proceed looks to be a boolean it is likely stored in the Bundle as a String and that is why you cannot get the value of it using bundle.getBoolean().

You should use bundle.getString("proceed"); instead.

You can parse the String into a boolean if you need to.

boolean proceed = Boolean.parseBoolean(bundle.getString("proceed", "false"));
like image 199
George Mulligan Avatar answered Jan 22 '26 23:01

George Mulligan