Starting Another Activity
[android/MyFirstApp.git] / src / com / example / myfirstapp / MainActivity.java
1 package com.example.myfirstapp;
2
3 import android.app.Activity;
4 import android.content.Intent;
5 import android.os.Bundle;
6 import android.view.View;
7 import android.widget.EditText;
8
9 public class MainActivity extends Activity
10 {
11     public final static String EXTRA_MESSAGE = "com.example.myfirstapp.MESSAGE";
12
13     /** Called when the activity is first created. */
14     @Override
15     public void onCreate(Bundle savedInstanceState)
16     {
17         super.onCreate(savedInstanceState);
18         setContentView(R.layout.main);
19     }
20
21     /** Called when the user clicks the Send button */
22     public void sendMessage(View view) {
23         Intent intent = new Intent(this, DisplayMessageActivity.class);
24         EditText editText = (EditText) findViewById(R.id.edit_message);
25         String message = editText.getText().toString();
26         intent.putExtra(EXTRA_MESSAGE, message);
27         startActivity(intent);
28     }
29 }