Activities are one of the fundamental building blocks of apps on the Android platform.
They serve as the entry point for a user's interaction with an app, and are also central to how a user navigates within an app.
It is also called container of views (Button, Textview n more).
Some Point
1. Android activity is subclass of ContextThemeWrapper class.
2. Activity starting with a call on OnCreate() method after that OnStart() and OnResume().
3. XML layout resource placed in setContentView() method to connect with code.
4. findViewbyId() method is use to initialize the view inside actvity.
Note : There are some method, Check Activity lifecycle
They serve as the entry point for a user's interaction with an app, and are also central to how a user navigates within an app.
It is also called container of views (Button, Textview n more).
Some Point
1. Android activity is subclass of ContextThemeWrapper class.
2. Activity starting with a call on OnCreate() method after that OnStart() and OnResume().
3. XML layout resource placed in setContentView() method to connect with code.
4. findViewbyId() method is use to initialize the view inside actvity.
Note : There are some method, Check Activity lifecycle
Implementing a user
interface
1. The user interface
for an activity is provided by a hierarchy of views—objects derived from the
View class.
2. Each view controls a particular rectangular
space within the activity's window and can respond to user interaction.
3. Android provides a
number of ready-made views that you can use to design and organize your layout.
1. "Widgets" are views that
provide visual (and interactive) elements for the screen, such as a button,
text field, checkbox, or just an image.
2.
"Layouts" are views derived from ViewGroup that provide a
unique layout model for its child views, such as a linear layout, a grid
layout, or relative layout.
Declaring the activity in
the manifest
Android studio
automatically (You can also) declare your activity in the manifest file in
order for it to be accessible to the system.
To declare activity manually, open your manifest file and add an <activity> element as a child of the <application> element.
To declare activity manually, open your manifest file and add an <activity> element as a child of the <application> element.
For example:
<manifest ... >
<application ... >
<activityandroid:name=".ExampleActivity"/>
...
</application ... >
...
</manifest>
The android:name - It
specifies the class name of the activity.
Using intent filters
Intent filter that declares the
activity responds to the "main" action and should be placed in the
"launcher" category. The intent filter looks like this:
<activityandroid:name=".ExampleActivity"android:icon="@drawable/app_icon">
<intent-filter>
<actionandroid:name="android.intent.action.MAIN"/>
<categoryandroid:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
1. The <action> element specifies that this
is the "main" entry point to the application.
2. The <category> element specifies that this
activity should be listed in the system's application launcher (to allow users
to launch this activity).
Shutting Down an Activity
finish() method - You can shut down an
activity by calling it.
finishActivity() - You can also shut down a separate activity
that you previously started by calling.
Activity has six states
Created
Started
Resumed
Paused
Stopped
Destroyed
Activity lifecycle has seven methods
onCreate()
onStart()
onResume()
onPause()
onStop()
onRestart()
onDestroy()
Activity has six states
Created
Started
Resumed
Paused
Stopped
Destroyed
Activity lifecycle has seven methods
onCreate()
onStart()
onResume()
onPause()
onStop()
onRestart()
onDestroy()
No comments:
Post a Comment