3

As is known to all, we can put the extra info into an Intent by using putExtra/putExtras, and pass it to another app. At the destination, we can use getxxxExtra/getExtras to get this information. However, all these methods request a key.

I was wondering if there is any way to obtain information without a key. Or, is there any way to check all the keys that have been set into the bundle?

Thanks in advance!

1 Answer 1

14

if there is any way to obtain information without a key.

No, there is no way to send data without any key, You need to use some sort of key whether it's Intent.EXTRA or your defined key

is there any way to check all the keys that have been set into the bundle?

Yes, you can use getIntent().getExtras().keySet() this will give you a Set (of String) containing all keys.

Bundle bundle = getIntent().getExtras();
Set<String> bundleKeySet = bundle.keySet(); // string key set
for(String key : bundleKeySet){ // traverse and print pairs
    Log.i(key," : " + bundle.get(key));
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.