
This is the idea behind Intents in Android. If you click a "compose new email" button, you are actively saying "I intend to compose an email". This translates to your app and activities every activity has a goal.įor example, a ComposeEmailActivity allows the user to compose and send an email. Intent, as defined in the dictionary, means: purpose, goal, objective. GetDoubleExtra(String name, double defaultValue)įloat getFloatExtra (String name, float defaultValue) getIntArrayExtra (String name) getIntExtra (String name, int defaultValue) getIntegerArrayListExtra (String name) getLongArrayExtra (String name) getLongExtra (String name, long defaultValue) getSerializableExtra (String name) getShortArrayExtra (String name) getShortExtra (String name, short defaultValue) getStringArrayExtra (String name) getStringArrayListExtra (String name) getStringExtra (String name) Introduction: What are Intents? (10 mins) GetCharSequenceArrayListExtra(String name) GetCharExtra(String name, char defaultValue)

GetByteExtra(String name, byte defaultValue) GetBooleanExtra(String name, boolean defaultValue)

Methods associated with getting extra information out of an intent. Int age = prevActivity.getIntExtra( "AGE", 0) Įxtras can store lots of types of information. String name = prevActivity.getStringExtra( "NAME") Get Extras Example Intent prevActivity = getIntent() MIntentToBeLame.putExtra( "MSG", message) String message = "hey main, plz learn 2 be chill and not call the RA next time" Put Extras Intent mIntentToBeLame = new Intent(SecondActivity.
Android studio intent putextra object how to#
Here's some simple examples of how to put extra information in an intent,Īnd how to get it out. The ViewInbox activity puts extra information in the intent that specifies The ReadEmail activity needs to know what email it's supposed to display.

Simply starting the ReadEmail activity isn't enough. ViewInbox activity, the activity needs to create a new intent to start a When someone clicks on an email in the inbox the Let's imagine there is a ViewInbox activityĪnd a ReadEmail activity. We can pass data between different activities when their started and when theyĮnd. Passing Data Between Activities using Extras Basic Terminal & Navigating the Filesystem
