Note
Note
1) introduction to android?
1. Linux kernal:
Security
Memory Management
Process Management
Network Stack
Driver Model
2. Platform libries:
3. Android runtime:
5. application layer:
5) Explain intent?
I. Implicit Intent:
Asks system to find an Activity that can handle this request.
Find an open store that sells green tea
Clicking Share opens a chooser with a list of apps
Example:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello, Android!" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Click Me" />
</LinearLayout>
2. RelativeLayout:
RelativeLayout allows you to position child
views relative to each other or relative to the parent layout.
You can use attributes like android:layout_alignParentTop,
android:layout_toEndOf
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button 1" />
<Button
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button 2"
android:layout_toEndOf="@+id/button1" />
</RelativeLayout>
3. FrameLayout:
FrameLayout is a simple layout that allows one
child view to be displayed at a time. It's often used for
displaying fragments or swapping views dynamically.
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/image"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@drawable/image1" />
<ProgressBar
android:id="@+id/progressBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center" />
</FrameLayout>
4. ConstraintLayout:
ConstraintLayout allows you to define
complex layouts with flexible positioning and constraints. It's
powerful and efficient for building responsive UIs.
<ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello, Android!" />
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Click Me"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@id/textView1" />
</ConstraintLayout>
View ViewGroup
View is a simple rectangle
ViewGroup is the invisible container.
box that responds to the
It holds View and ViewGroup
user’s actions.
View is the SuperClass of All ViewGroup is a collection of
component like TextView, Views(TextView, EditText, ListView,
EditText, ListView, etc etc..), somewhat like a container.
A View object is a component
A ViewGroup object is a layout, that
of the user interface (UI)
is, a container of other ViewGroup
like a button or a text box,
objects (layouts) and View objects
and it’s also called a
(widgets)
widget.
For example, LinearLayout is the
Examples are EditText,
ViewGroup that contains Button(View),
Button, CheckBox, etc.
and other Layouts also.
View refers to the ViewGroup refers to the
android.view.View class android.view.ViewGroup class
android.view.View which is
ViewGroup is the base class for
the base class of all UI
Layouts.
classes.
4) Explain ListView?
Attribute Description
android:divider A color or drawable to separate list items.
android:dividerHeight Divider’s height.
Reference to an array resource that will
android:entries
populate the ListView.
1. The Card Layout: The card layout is an XML layout which will be
treated as an item for the list created by the RecyclerView.
2. The ViewHolder: The ViewHolder is a java class that stores the
reference to the card layout views that have to be dynamically
modified during the execution of the program by a list of data
obtained either by online databases or added in some other way.
3. The Data Class: The Data class is a custom java class that acts
as a structure for holding the information for every item of
the RecyclerView.
RecyclerView ListView
The RecyclerView’s adaptor forces us The ListView doesn’t give that
to use the ViewHolder pattern. The kind of protection by default,
views are split into so without implementing the
onCreateViewholder() and ViewHolder pattern inside the
onBindViewholder() methods. getView().
Efficient Scrolling, we can choose
Inefficient scrolling, we can
the way of scroll-like vertically or
only create vertical scrolling.
horizontally and grids.
More memory is used for a long
Use of less memory. list. Sometimes devices get
hanged.
Animations using ItemAnimator are
easy and smooth. Animations like list
It’s complex to use Animation
appearance and disappearance, adding
and hard to handle it.
or removing particular views, and so
on.
Dividers between items are not shown Dividers between items are
by default. shown by default.
Use ItemDecorations to add margins ItemDecorations require
and draw on or under an item View. customization.
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.game_menu, menu);
return true;
}
2. Context menu:
@Override
public void onCreateContextMenu(ContextMenu menu, View v,
ContextMenuInfo menuInfo)
{
super.onCreateContextMenu(menu, v, menuInfo);
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.context_menu, menu);
}
3. popup menu:
1) Storage in android.
<uses-permission
android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission
android:name="android.permission.READ_EXTERNAL_STORAGE" />
if (Environment.MEDIA_MOUNTED.equals(state)) {
return true;
return false;
SharedPreferences sharedpreferences =
getSharedPreferences(“Settings”, Context.MODE_PRIVATE);
10.registerOnSharedPreferencechangeListener(SharedPreferences.OnS
haredPreferencechangeListener listener): This method is used
to register a callback to be invoked when a change happens to a
preference.
11. unregisterOnSharedPreferencechangeListener(SharedPreferences.O
nSharedPreferencechangeListener listener): This method is used
to unregister a previous callback.
5) Explain SQLite database?
1. Text(lik String)
2. Integer (like int)
3. Real(like double)
It is a lightweight database.
Required very little memory
Am autometically manage database.
6) Content provider?
1)