Basic Intro to android(Will be updating later)

14

description

Basic Intro to android application development. Taken from a 2 hour sessions. Covers very basic topics. (Will upload an advanced elaborate slide later) Session Taken at Illahia.

Transcript of Basic Intro to android(Will be updating later)

Page 1: Basic Intro to android(Will be updating later)
Page 2: Basic Intro to android(Will be updating later)

Download the Android SDK.

Install the ADT plugin for Eclipse (if you’ll use the Eclipse IDE).

Download the latest SDK tools and platforms using the SDK Manager.

Page 3: Basic Intro to android(Will be updating later)

Creating an Android Project

Page 4: Basic Intro to android(Will be updating later)

Running Your App

1. Run on a Real Device

2. Run on the Emulator

Page 5: Basic Intro to android(Will be updating later)

Directories and Files in the Android project

Page 6: Basic Intro to android(Will be updating later)

Building a Simple User Interface

Page 7: Basic Intro to android(Will be updating later)

android:onClick="sendMessage"

public void sendMessage(View view) {

// Do something in response to button

}

Page 8: Basic Intro to android(Will be updating later)

Build an Intent

Intent intent = new Intent(this, DisplayMessageActivity.class);

To provides runtime binding between separate components(as two activities)

Page 9: Basic Intro to android(Will be updating later)

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);

public class MainActivity extends ActionBarActivity {

public final static String EXTRA_MESSAGE = "com.example.myfirstapp.MESSAGE";

...

}

Page 10: Basic Intro to android(Will be updating later)

/** Called when the user clicks the Send button */

public void sendMessage(View view) {

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);

}

Page 11: Basic Intro to android(Will be updating later)

Create the Second Activity

Page 12: Basic Intro to android(Will be updating later)

Receive the Intent

Intent intent = getIntent();String message = intent.getStringExtra(MainActivity.EXTRA_MESSAGE);

Page 13: Basic Intro to android(Will be updating later)

@Override

public void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

// Get the message from the intent

Intent intent = getIntent();

String message = intent.getStringExtra(MainActivity.EXTRA_MESSAGE);

// Create the text view

TextView textView = new TextView(this);

textView.setTextSize(40);

textView.setText(message);

// Set the text view as the activity layout

setContentView(textView);

}

Page 14: Basic Intro to android(Will be updating later)