I called them “binding intents” just to point that we are going to talk about Intents that binds Activities, so we can pass information from one place to another.
Lets think of these intents using two examples:
-Example A: We need to give some information to a new Activity we are going to create now. This information will be for this example a phone number. In your first Activity you click a contact from a list of contacts, you then want to open a new window with this contact information in a new and amazing User Interface.
In the ActivityA.java
Intent intent = new Intent("name.of.the.ActivityB");
intent.putExtra("INFO_TO_PASS", variableToPass);
We create a new Intent, using the name of the ActivityB we have set in the AndroidManifest.xml.
<activity android:name=".BrightHub.ActivityB">
<intent-filter>
<action android:name="name.of.the.ActivityB" />
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</activity>
Where in “name.of.the.ActivityB” you can set the value you want.
We put the info we want to send in the “putExtra” method, we set a name to remember “INFO_TO_PASS” in this example, and the concrete info we want in the ActivityB.
In the ActivityB.java
Bundle extras = getIntent().getExtras();
variableGet = extras.getInt("INFO_TO_PASS");
Here we create a new Bundle object to get the information from the Intent. We can use “getInt”, “getString”, “getByte” to get the information. This method is similar to the GET and POST methods when we work in web programming environment.