Intent In Android Studio

Build an intent

An Intent is an object that provides runtime binding between separate components, such as two activities. The Intent represents an app’s intent to do something. You can use intents for a wide variety of tasks, but in this lesson, your intent starts another activity.

In MainActivity, add the EXTRA_MESSAGE constant and the sendMessage() code, as shown:


public class MainActivity extends AppCompatActivity {
    public static final String EXTRA_MESSAGE = "com.example.myfirstapp.MESSAGE";
    protected void onCreate(Bundle savedInstanceState) {

    /** Called when the user taps the Send button */
    public void sendMessage(View view) {
        Intent intent = new Intent(this, DisplayMessageActivity.class);
        EditText editText = (EditText) findViewById(;
        String message = editText.getText().toString();
        intent.putExtra(EXTRA_MESSAGE, message);


const val EXTRA_MESSAGE = "com.example.myfirstapp.MESSAGE"

class MainActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {

    /** Called when the user taps the Send button */
    fun sendMessage(view: View) {
        val editText = findViewById<EditText>(
        val message = editText.text.toString()
        val intent = Intent(this, {
            putExtra(EXTRA_MESSAGE, message)

8 Replies to “Intent In Android Studio”

  1. Learning curve hypotheses prototype early adopters focus channels direct mailing business-to-business vesting period. Equity seed round funding advisor partnership vesting period channels niche market social media business plan long tail. Startup deployment partner network holy grail pivot bootstrapping product management accelerator virality churn rate business-to-consumer network effects seed round. Influencer client startup. Maddi Kipp Zalucki

  2. Hey! Someone in my Myspace group shared this site with
    us so I came to give it a look. I’m definitely enjoying the information. I’m bookmarking and will be tweeting this to my followers!
    Superb blog and terrific design.

Leave a Reply

Your email address will not be published. Required fields are marked *