•An activity presents a visual
user interface for one focused endeavor the
user can undertake.
•An application might
consist of just one activity or many.
•Each one is
implemented as a subclass of the Activity base class
An
An application usually consists of multiple activities that are loosely bound to each other. Typically, one activity in an application is specified as the "main" activity, which is presented to the user when launching the application for the first time. Each activity can then start another activity in order to perform different actions. Each time a new activity starts, the previous activity is stopped, but the system preserves the activity in a stack (the "back stack"). When a new activity starts, it is pushed onto the back stack and takes user focus..
You can start another activity by calling
An
Activity
is an application component that provides a screen with which
users can interact in order to do something, such as dial the phone, take a photo, send an email, or
view a map. Each activity is given a window in which to draw its user interface. An application usually consists of multiple activities that are loosely bound to each other. Typically, one activity in an application is specified as the "main" activity, which is presented to the user when launching the application for the first time. Each activity can then start another activity in order to perform different actions. Each time a new activity starts, the previous activity is stopped, but the system preserves the activity in a stack (the "back stack"). When a new activity starts, it is pushed onto the back stack and takes user focus..
Declaring Activity In Manifest
<manifest ... >
<application ... >
<activity android:name=".ExampleActivity" />
...
</application ...>
</manifest >
Using Intent Filters In Activity Tag
<activity android:name=".ExampleActivity" android:icon="@drawable/app_icon">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
The <action>
element specifies that this is the "main" entry point to the application.
The <category>
element specifies that this activity should be listed in the
system's application launcher (to allow users to launch this activity).
Starting An Activity:
You can start another activity by calling startActivity()
, passing it an Intent
that describes the activity you
want to start. The intent specifies either the exact activity you want to start or describes the
type of action you want to perform
Intent intent = new Intent(this, SignInActivity.class); startActivity(intent);
Implementing the lifecycle callbacks:
When an activity transitions into and out of the different states described above, it is notified through various callback methods. All of the callback methods are hooks that you can override to do appropriate work when the state of your activity changes. The following skeleton activity includes each of the fundamental lifecycle methods:
public class ExampleActivity extends Activity { @Override public voidonCreate
(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // The activity is being created. } @Override protected voidonStart()
{ super.onStart(); // The activity is about to become visible. } @Override protected voidonResume()
{ super.onResume(); // The activity has become visible (it is now "resumed"). } @Override protected voidonPause()
{ super.onPause(); // Another activity is taking focus (this activity is about to be "paused"). } @Override protected voidonStop()
{ super.onStop(); // The activity is no longer visible (it is now "stopped") } @Override protected voidonDestroy()
{ super.onDestroy(); // The activity is about to be destroyed. } }
More Android Topics
Android : Introduction
Eclipse Setup for Android Development
Begging With Android
Working With Layouts
Activity
Working With Views
Dialogs In Android
DatePicker and TimePickerDialog
Working With SMS
ListView:
Menus In Android
TelephonyManager
Working With Incoming Calls
Miscellaneous
Storage: Storing Data In Android
Shared Prefferences In Android
Files: File Handling In Android
DataBase : Working With Database
Animation In Android:
Aivivu chuyên vé máy bay, tham khảo
ReplyDeletevé máy bay đi Mỹ tháng nào rẻ nhất
gia ve may bay ve vn
mua ve may bay gia re tu duc ve viet nam
vé máy bay từ nga về việt nam
giá vé máy bay từ anh về việt nam
các chuyến bay từ châu âu về việt nam
giá khách sạn cách ly ở hà nội
chuyến bay chuyên gia trung quốc
Aivivu chuyên vé máy bay, tham khảo
ReplyDeletevé máy bay đi Mỹ giá rẻ
các chuyến bay từ mỹ về việt nam
ve may bay tư duc ve viet nam
vé máy bay từ nga về tphcm
giá thuê máy bay từ anh về việt nam
chuyến bay từ paris về hà nội
danh sách khách sạn cách ly đà nẵng
vé máy bay chuyên gia nước ngoài sang Việt Nam