Skip to content
Advertisement

Tag: android-intent

Convert a Bundle to JSON

I’d like to convert the an Intent’s extras Bundle into a JSONObject so that I can pass it to/from JavaScript. Is there a quick or best way to do this conversion? It would be alright if not all possible Bundles will work. Answer You can use Bundle#keySet() to get a list of keys that a Bundle contains. You can then

In Activity.onCreate(), why does Intent.getExtras() sometimes return null?

This was probably a false alarm, see my own answer. Original question below: An activity has a button that takes the user to another activity. To launch the new activity, we populate our Intent with extras, and onCreate(), the new activity reads from those extras via Intent.getExtras(). We assumed the returned bundle would be non-null, but as customer crash reports

Advertisement