1 package com.example.myfirstapp;
3 import android.annotation.SuppressLint;
4 import android.app.Activity;
5 import android.content.Intent;
6 import android.os.Build;
7 import android.os.Bundle;
8 import android.support.v4.app.NavUtils;
9 import android.view.MenuItem;
10 import android.widget.TextView;
12 public class DisplayMessageActivity extends Activity {
14 @SuppressLint("NewApi")
16 protected void onCreate(Bundle savedInstanceState) {
17 super.onCreate(savedInstanceState);
18 // Get the message from the intent
19 Intent intent = getIntent();
20 String message = intent.getStringExtra(MainActivity.EXTRA_MESSAGE);
22 // Create the text view
23 TextView textView = new TextView(this);
24 textView.setTextSize(40);
25 textView.setText(message);
27 // Set the text view as the activity layout
28 setContentView(textView);
31 // Make sure we're running on Honeycomb or higher to use ActionBar APIs
32 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
33 // Show the Up button in the action bar.
34 getActionBar().setDisplayHomeAsUpEnabled(true);
39 public boolean onOptionsItemSelected(MenuItem item) {
40 switch (item.getItemId()) {
41 case android.R.id.home:
42 NavUtils.navigateUpFromSameTask(this);
45 return super.onOptionsItemSelected(item);