Collect all the Extras of an Intent

2

Is there any way to find out what all the Extras in an Intent are!

CONTEXT :

I have an app that gets url's shared by the other apps:

if (Intent.ACTION_SEND.equals(action)) {

    final String url_ = i.getStringExtra(Intent.EXTRA_TEXT);
    if(null != url_){
        urls.add(url_);
    }
}

I would like to know which parameters besides Intent.EXTRA_TEXT this Intent have?

    
asked by anonymous 07.01.2017 / 16:46

1 answer

5

For those who are not yet familiar, Intent 's enable information to be transmitted from one screen to another as the user navigates the application.

  

An intent is an abstract description of an operation to be performed.

According to the documentation , below is the current values of type EXTRA_[...] that can be used as extra data via putExtra (String, Bundle) using the Intent class. Remember that it is not only these that can be passed via Intent . See:

  • EXTRA_ALARM_COUNT
  • EXTRA_BCC
  • EXTRA_CC
  • EXTRA_CHANGED_COMPONENT_NAME
  • EXTRA_DATA_REMOVED
  • EXTRA_DOCK_STATE
  • EXTRA_DOCK_STATE_HE_DESK
  • EXTRA_DOCK_STATE_LE_DESK
  • EXTRA_DOCK_STATE_CAR
  • EXTRA_DOCK_STATE_DESK
  • EXTRA_DOCK_STATE_UNDOCKED
  • EXTRA_DONT_KILL_APP
  • EXTRA_EMAIL
  • EXTRA_INITIAL_INTENTS
  • EXTRA_INTENT
  • EXTRA_KEY_EVENT
  • EXTRA_ORIGINATING_URI
  • EXTRA_PHONE_NUMBER
  • EXTRA_REFERRER
  • EXTRA_REMOTE_INTENT_TOKEN
  • EXTRA_REPLACING
  • EXTRA_SHORTCUT_ICON
  • EXTRA_SHORTCUT_ICON_RESOURCE
  • EXTRA_SHORTCUT_INTENT
  • EXTRA_STREAM
  • EXTRA_SHORTCUT_NAME
  • EXTRA_SUBJECT
  • EXTRA_TEMPLATE
  • EXTRA_TEXT
  • EXTRA_TITLE
  • EXTRA_UID

To redeem all values saved in Intent you can foreach by traversing bundle using keySet() . See below:

if (bundle != null) {
    for (String chave : bundle.keySet()) {
        Object value = bundle.get(chave);
        Log.d(TAG, String.format("%s %s (%s)", chave, 
             value.toString(), value.getClass().getName()));
    }
}
    
07.01.2017 / 17:12