diff --git a/AndroidManifest.xml b/AndroidManifest.xml index 42a7d51..95f8615 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -11,5 +11,12 @@ + + + diff --git a/res/values/strings.xml b/res/values/strings.xml index e46c64e..e523daa 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -5,4 +5,5 @@ Send Settings MainActivity + DisplayMessageActivity diff --git a/src/com/jinfield/sampleapp/DisplayMessageActivity.java b/src/com/jinfield/sampleapp/DisplayMessageActivity.java new file mode 100644 index 0000000..3f19b15 --- /dev/null +++ b/src/com/jinfield/sampleapp/DisplayMessageActivity.java @@ -0,0 +1,25 @@ +package com.jinfield.sampleapp; + +import android.app.Activity; +import android.os.Bundle; +import android.content.Intent; +import android.widget.TextView; + +public class DisplayMessageActivity extends Activity { + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + // Recieve message from the intent + Intent intent = getIntent(); + String message = intent.getStringExtra(MainActivity.EXTRA_MESSAGE); + + // Create TextView + TextView textView = new TextView(this); + textView.setTextSize(40); + textView.setText(message); + + // Set textView as activity layout + setContentView(textView); + } +} diff --git a/src/com/jinfield/sampleapp/MainActivity.java b/src/com/jinfield/sampleapp/MainActivity.java index ee8b6d6..1479bfb 100644 --- a/src/com/jinfield/sampleapp/MainActivity.java +++ b/src/com/jinfield/sampleapp/MainActivity.java @@ -3,9 +3,13 @@ package com.jinfield.sampleapp; import android.app.Activity; import android.os.Bundle; import android.view.View; +import android.content.Intent; +import android.widget.EditText; public class MainActivity extends Activity { + public final static String EXTRA_MESSAGE = "com.jinfield.sampleapp.MESSAGE"; + /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) @@ -15,6 +19,10 @@ public class MainActivity extends Activity } /** Called whe user clicks the send Button */ public void sendMessage(View view) { - // TODO + Intent intent = new Intent(this, DisplayMessageActivity.class); + EditText editText = (EditText) findViewById(R.id.edit_message); + String message = editText.getText().toString(); + intent.putExtra(EXTRA_MESSAGE, message); + startActivity(intent); } }