You are on page 1of 13

Activity

Provides a visual interface for user interaction


Typically supports one thing a user can do

View an email message


Show a login screen

Applications can include several activities

A Task is a set of related Activities


Task not necessarily provided by a single

application

Android manages an Activity back stack

Launching an Activity places it on top of the stack


Hitting back button pops current Activity o the

stack

developer.android.com/guide/topics/fundamentals/tasks-and-back-stack.html

Simple Ac*vity
Create Android application
Add new button & add android:onClik attribute to
the <Button> element
Put the method name in the value of
android:onClik attribute
example android:onClick =startsecondAc+vity
Add new activity ( File->New->Other->Android-
>Android Activity)

Simple Ac*vity
Create Android application
Add new button & add android:onClik attribute to
the <Button> element
Put the method name in the value of
android:onClik attribute
example android:onClick =startsecondAc+vity
Add new activity ( File->New->Other->Android-
>Android Activity)
Example name Second

Intent
An Intent is an object that provides runtime binding
between separate components (such as two
activities).
The Intent represents an apps "intent to do
something.
Most often theyre used to start another activity.

Start Second Ac*vity


in the method startsecondActivity create the
intent to start activity called Second
Create intent inside the method
Call the intent
public void startsecondActivity (View view){
Intent viewSecond = new Intent (this, Second.class);
startActivity(viewSecond);
}

Not started not yet created


Active

Resumed/Running --- visible, has focus


Paused --- visible, does not have focus, can be

terminated
Stopped --- not visible, does not have focus,
can be terminated

Finished done

Android communicates state changes to


application by calling specic lifecycle
methods

protected void onCreate()


protected void onStart()
protected void onResume()
protected void onPause()
protected void onRestart()
protected void onStop()
protected void onDestroy()

Tugas
Buatlah sebuah aplikasi terdiri dari 3 ac*vity
Kirimkan text/pesan ke ac*vity berikutnya yg
diak*?an
h@p://developer.android.com/training/
basics/rstapp/star*ng-ac*vity.html

You might also like