LECTURE 2
LECTURE 2
Among many other things, the manifest file is required to declare the following:
• The app's package name.
usually matches your code's namespace. The Android build tools use this to
determine the location of code entities when building your project. When
packaging the app, the build tools replace this value with the application ID
from the Gradle build files, which is used as the unique app identifier on the
system and on Google Play.
Android Project Structure (Manifest file)
An intent-filter
This is a tag used in the manifest file of your app, generally for two
basic reasons:-
To specify which activity of your app is going to be
the launcher activity(the home screen).
It is used to register broadcast receivers or services.
Android Project Structure (Manifest file)
App components
For each app component that you create in your app, you must declare a
corresponding XML element in the manifest file:
<activity> for each subclass of Activity.
<service> for each subclass of Service.
<receiver> for each subclass of BroadcastReceiver.
<provider> for each subclass of ContentProvider.
If you subclass any of these components without declaring it in the manifest
file, the system cannot start it.
Android Project Structure (Manifest file)
Permissions
Android apps must request permission to access sensitive user data (such as
contacts and SMS) or certain system features (such as the camera and internet
access).
Each permission is identified by a unique label.
For example, an app that needs to send SMS messages must have the following
line in the manifest:
<manifest ... >
<uses-permission android:name="android.permission.SEND_SMS"/>
...
</manifest>
Android Project Structure (Manifest file)
Device compatibility
The manifest file is also where you can declare what types of hardware or
software features your app requires, and thus, which types of devices your app is
compatible with.
Google Play Store does not allow your app to be installed on devices that don't
provide the features or system version that your app requires.
There are several manifest tags that define which devices your app is compatible
with.
The following are just a couple of the most common tags.
Android Project Structure (Manifest file)
<uses-feature>
The <uses-feature> element allows you to declare hardware and software features
your app needs. For example, if your app cannot achieve basic functionality on a
device without a compass sensor, you can declare the compass sensor as required
with the following manifest tag:
<uses-sdk>
Each successive platform version often adds new APIs not available in the
previous version.
To indicate the minimum version with which your app is compatible, your
manifest must include the <uses-sdk> tag and its minSdkVersion attribute.
Android Project Structure (Java folder)
Java folder contains all the java and Kotlin source code (.java) files which we
create during the app development, including other Test files.
If we create any new project using java, by default the class file
MainActivity.java file will create automatically under the package name
“com.example.myapplication1” like as shown below.
Android Project Structure (Java folder)
Android Project Structure (Resource (res) folder)
res/drawable folder
It contains the different type of images used for the development of
the application.
We need to add all the images in drawable folder for the application
development.
Android Project Structure (Resource (res) folder)
res/layout folder
Layout folder contains all XML layout files which we used to define
the user Interface of our application.
It contains the activity_main.xml file.
Android Project Structure (Resource (res) folder)
res/mipmap folder
This folder contains launcher.xml files to define icons which are used
to show on the home screen.
It contains different density type of icons depends upon the size of the
device such as hdpi, mdpi, xhdpi.
Android Project Structure (Resource (res) folder)
res/values folder
Values folder contains a number of XML files like strings, dimens,
colors and styles definitions.
One of the most important file is strings.xml file which contains the
resources.
Android Project Structure (Resource (res) folder)
A menu
This resource defines an application menu (Options Menu, Context
Menu, or submenu) that can be inflated with MenuInflater.
Android Project Structure (Gradle Scripts folder)
android:layout_marginTop
This is the extra space on the top
side of the layout.
Layouts in android(common properties)
android:layout_marginBottom
This is the extra space on the bottom side of the layout.
android:layout_marginLeft
This is the extra space on the left side of the layout.
android:layout_marginRight
This is the extra space on the right side of the layout.
android:layout_gravity
This specifies how child Views are positioned.
Layouts in android(common properties)
android:layout_weight
This specifies how much of the extra space in the layout
should be allocated to the View.
Layouts in android(Relative Layout)
RelativeLayout is a view group that displays child views in relative positions.
RelativeLayout enables you to specify how child views are positioned relative to
each other.
The position of each view
can be specified as relative to
sibling elements or relative to the parent.
Layouts in android(Table Layout)
TableLayout - displays elements in the form of a table, with rows and
columns.
Android UI Controls
There are number of UI controls provided by Android that
allow you to build the graphical user interface for your app.
A TextView displays text to the user and optionally allows
them to edit it.
A TextView is a complete text editor, however the basic class
is configured to not allow editing.
Android UI Controls(attributes of text view)
android:id
This is the ID which uniquely identifies the control.
android:capitalize
If set, specifies that this TextView has a textual input method and should automatically capitalize
what the user types.
android:hint
Hint text to display when the text is empty.
android:password
Whether the characters of the field are displayed as password dots instead of themselves. Possible
value either "true" or "false".
Android UI Controls(Edit Text)
A EditText is an overlay over TextView that configures itself to be
editable.
It is the predefined subclass of TextView that includes rich editing
capabilities.
Android UI Controls(Button)
A Button is a Push-button which can be pressed, or clicked, by the
user to perform an action.
Android UI Controls(Check Box)
A CheckBox is an on/off switch that can be toggled by the
user.
You should use check-boxes when presenting users with a
group of selectable options that are not mutually exclusive.
Android UI Controls(Radio Button)
A RadioButton has two states: either checked or unchecked.
This allows the user to select one option from a set.
Android UI Controls(Spinner)
Spinner allows you to select an item from a drop down
menu
END