SlideShare a Scribd company logo
1 of 20
Android Application
Structure
Prepared By: Ms. Sokngim Sa
Content
- AndroidManifest.xml
- Resources
- Assets
3.1. The Android Manifest File
3.1.1 Configuration of your Android Application
- The components, settings and metadata, APIs Level and Hardware or software
of an Android application are described in the AndroidManifest.xml file.
- The manifest is read by the Android system during installation of the
application.
3.1.2
Android
Manifest
Example
3.1.3 Version and Package
- The package attribute defines the base package for the Java objects referred to
in this file.
- Google Play requires that every Android application uses its own unique
package name. Therefore it is a good habit to use your reverse domain name
here. This will avoid collisions with other Android applications.
- android:versionName and android:versionCode specify the version of your
application. versionName is what the user sees and can be any string.
- versionCode must be an integer. The Android Market determines whether it
should perform an update of the applications for the existing installation based
3.1.4 Application and Component
- The <application> is a container for declaring other Android components.
- The <activity> tag defines an activity. The name attribute points to class, which (if not fully
qualified) is relative to the package defined in the`package` attribute.
- The intent filter part in the Android manifest file, tells the Android runtime that this activity should be
registered as a possible entry point into the application and made available in the launcher of the
Android system. The action defines that it ( android:name="android.intent.action.MAIN" ` ) can be
started. The `category android:name="android.intent.category.LAUNCHER" parameter tells the
Android system to add the activity to the launcher.
- The <@string/app_name> value refers to resource files which contain the actual value of the
application name. The usage of a resource file makes it easy to provide different resources (e.g.,
strings, colors, icons) for different devices and makes it easy to translate applications.
3.1.4 Minimum and target SDK
minSdkVersion: Define the minimum
version of Android your application
works on. This attribute is used as a
filter in applications stores Play. A
user cannot install your application on
a device with a lower API level than
specified in this attribute.
targetSdkVersion: Specifies the
version on which you tested and
developed. If it is not equal to the API
version of the Android device, the
Android system might apply forward-
or backward-compatibility changes. It
is good practice to always set this to
the latest Android API version to take
advantages of changes in the latest
Android improvements.
3.1.5 Permissions
- The Android manifest file must also contain the required permissions for the
application. For example, if the application requires network access, it must be
specified here.
- Your application can declare permissions with the <permission> tag and
declare that it required a permission with the <uses-permission> tag.
- Certain permissions, like network access, are granted automatically on Android
6.0 or higher systems. Other permissions must be confirmed by the users to
become active.
3.1.6 Required Device Configuration
- The uses-configuration section in the manifest allows you to specify required
input methods for your device. For example, the following snippet would require
that the device has a hardware keyboard.
<uses-configuration android:reqHardKeyboard="true"/>
- The uses-feature section allows you to specify the required hardware
configuration for your device. For example, the following snippet would require
that the device has a camera.
<uses-feature android:name="android.hardware.camera" />
3.2 Resources
3.2.1 Resource Introduction
- Externalize Resource has such as image, string, layout,...
- There are 2 kind of Resource: Default and Alternative resources.
- Example : res/layout vs res/layout-land
- Externalize Resource allows alternative resource that support specific device
configurations such as different languages or screen sizes.
- At runtime, Android uses the appropriate resource based on the current
configuration.
3.2.2 Resource Type
Directory Resource Type
animator/ XML files that define property animations.
anim/ XML files that define tween animations. (Property animations can also be saved in
this directory, but the animator/ directory is preferred for property animations to
distinguish between the two types.)
color/ XML files that define a state list of colors
drawable/ Bitmap files (.png, .9.png, .jpg, .gif) or XML files that are compiled into the
following drawable resource subtypes:
Bitmap files, Nine-Patches (re-sizable bitmaps), State lists, Shapes, Animation
drawables, Other drawables
mipmap/ Drawable files for different launcher icon densities.
layout/ XML files that define a user interface layout
Directory Resource Type
menu/ XML files that define application menus, such as an Options Menu, Context Menu, or Sub Menu
raw/ Arbitrary files to save in their raw form. To open these resources with a raw InputStream, call
Resources.openRawResource() with the resource ID, which is R.raw.filename.
However, if you need access to original file names and file hierarchy, you might consider saving
some resources in the assets/ directory (instead of res/raw/). Files in assets/ are not given a
resource ID, so you can read them only using AssetManager.
values/ XML files that contain simple values, such as strings, integers, and colors.
arrays.xml for resource arrays (typed arrays).
colors.xml for color values
dimens.xml for dimension values.
strings.xml for string values.
styles.xml for styles.
xml/ Arbitrary XML files that can be read at runtime by calling Resources.getXML(). Various XML
configuration files must be saved here, such as a searchable configuration.
font/ Font files with extensions such as .ttf, .otf, or .ttc, or XML files that include a <font-family>
element. For more information about fonts as resources, go to Fonts in XML.
3.2.3 Alternative Resource
- Alternative Resource - <resources_name>-<config_qualifier>.
- <resources_name> is the directory name of the corresponding default resources (defined in table 1).
- <qualifier> is a name that specifies an individual configuration for which these resources are to be
used (defined in table 2)
- Example
res/
drawable/
icon.png
background.png
drawable-hdpi/
icon.png
Background.png
- Details - https://developer.android.com/guide/topics/resources/providing-
resources.html#ResourceTypes
3.2.4 Resource Accessing
- There are two ways to access a resource:
- In code: Using a static integer from a sub-class of your R class, such as:
● R.string.hello
● string is the resource type and hello is the resource name. There are many Android APIs
that can access your resources when you provide a resource ID in this format.
- In XML: Using a special XML syntax that also corresponds to the resource ID defined in your R
class, such as:
● @string/hello
● string is the resource type and hello is the resource name. You can use this syntax in an
XML resource any place where a value is expected that you provide in a resource.
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="opaque_red">#f00</color>
<string name="hello">Hello!</string>
</resources>
res/values/string.xml
3.3 Asset
3.3.1 Asset Introduction
- assets/ directory (instead of res/raw/).
- Files in assets/ are not given a resource ID, so you can read them only using
AssetManager.
Example of Using Assets
Java code:
WebView wv = (WebView)this.findViewById(R.id.splashWebView);
wv.setWebViewClient(new WebViewClient() {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url)
{
view.loadUrl(url);
return true;
}
});
wv.loadUrl("file:///android_asset/html_no_copy/demo_welcome.html");
demo_welcome.html:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Demo Html</title>
<link rel="stylesheet" type="text/css" href="demo.css" />
</head>
<body>
<H1>Testing One Two Three</H1>
<a href="test.html">CLICK HERE</a><p>
<a href="file:///android_asset/html_no_copy/test.html">OR HERE</a>
</body>
</html>
test.html:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<link rel="stylesheet" type="text/css" href="test.css" />
<title>Insert title here</title>
</head>
<body>
<H1>TEST.HTML</H1>
</body>
</html>

More Related Content

Similar to 03 android application structure

Android Resources.docx
Android Resources.docxAndroid Resources.docx
Android Resources.docxKNANTHINIMCA
 
Android application structure
Android application structureAndroid application structure
Android application structureAlexey Ustenko
 
Android Training Ahmedabad , Android Course Ahmedabad, Android architecture
Android Training Ahmedabad , Android Course Ahmedabad, Android architectureAndroid Training Ahmedabad , Android Course Ahmedabad, Android architecture
Android Training Ahmedabad , Android Course Ahmedabad, Android architectureNicheTech Com. Solutions Pvt. Ltd.
 
Android App Development 08 : Support Multiple Devices
Android App Development 08 : Support Multiple DevicesAndroid App Development 08 : Support Multiple Devices
Android App Development 08 : Support Multiple DevicesAnuchit Chalothorn
 
Android structure
Android structureAndroid structure
Android structureKumar
 
Synapseindia android apps introduction hello world
Synapseindia android apps introduction hello worldSynapseindia android apps introduction hello world
Synapseindia android apps introduction hello worldTarunsingh198
 
Android resource
Android resourceAndroid resource
Android resourceKrazy Koder
 
Android studio 2.0: default project structure
Android studio 2.0: default project structureAndroid studio 2.0: default project structure
Android studio 2.0: default project structureVyara Georgieva
 
Android Application Fundamentals
Android Application FundamentalsAndroid Application Fundamentals
Android Application FundamentalsVikalp Jain
 
Android project architecture
Android project architectureAndroid project architecture
Android project architectureSourabh Sahu
 
Android App Development - 03 Resources
Android App Development - 03 ResourcesAndroid App Development - 03 Resources
Android App Development - 03 ResourcesDiego Grancini
 
Training Session 2 - Day 2
Training Session 2 - Day 2Training Session 2 - Day 2
Training Session 2 - Day 2Vivek Bhusal
 
Android security by ravi-rai
Android security by ravi-raiAndroid security by ravi-rai
Android security by ravi-raiRavi Rai
 
Android Resource Manager
Android Resource ManagerAndroid Resource Manager
Android Resource ManagerSandeep Marathe
 
Android style resource and other resources types-chapter12
Android style resource and other resources types-chapter12Android style resource and other resources types-chapter12
Android style resource and other resources types-chapter12Dr. Ramkumar Lakshminarayanan
 
mobile application development -unit-3-
mobile application development  -unit-3-mobile application development  -unit-3-
mobile application development -unit-3-TejamFandat
 

Similar to 03 android application structure (20)

Android Resources.docx
Android Resources.docxAndroid Resources.docx
Android Resources.docx
 
Android resources in android-chapter9
Android resources in android-chapter9Android resources in android-chapter9
Android resources in android-chapter9
 
Android Programming.pptx
Android Programming.pptxAndroid Programming.pptx
Android Programming.pptx
 
Android application structure
Android application structureAndroid application structure
Android application structure
 
Android Training Ahmedabad , Android Course Ahmedabad, Android architecture
Android Training Ahmedabad , Android Course Ahmedabad, Android architectureAndroid Training Ahmedabad , Android Course Ahmedabad, Android architecture
Android Training Ahmedabad , Android Course Ahmedabad, Android architecture
 
Android App Development 08 : Support Multiple Devices
Android App Development 08 : Support Multiple DevicesAndroid App Development 08 : Support Multiple Devices
Android App Development 08 : Support Multiple Devices
 
Android structure
Android structureAndroid structure
Android structure
 
Synapseindia android apps introduction hello world
Synapseindia android apps introduction hello worldSynapseindia android apps introduction hello world
Synapseindia android apps introduction hello world
 
Android resource
Android resourceAndroid resource
Android resource
 
Android studio 2.0: default project structure
Android studio 2.0: default project structureAndroid studio 2.0: default project structure
Android studio 2.0: default project structure
 
Android Application Fundamentals
Android Application FundamentalsAndroid Application Fundamentals
Android Application Fundamentals
 
Android project architecture
Android project architectureAndroid project architecture
Android project architecture
 
Lesson 10
Lesson 10Lesson 10
Lesson 10
 
Android App Development - 03 Resources
Android App Development - 03 ResourcesAndroid App Development - 03 Resources
Android App Development - 03 Resources
 
Android Development Basics
Android Development BasicsAndroid Development Basics
Android Development Basics
 
Training Session 2 - Day 2
Training Session 2 - Day 2Training Session 2 - Day 2
Training Session 2 - Day 2
 
Android security by ravi-rai
Android security by ravi-raiAndroid security by ravi-rai
Android security by ravi-rai
 
Android Resource Manager
Android Resource ManagerAndroid Resource Manager
Android Resource Manager
 
Android style resource and other resources types-chapter12
Android style resource and other resources types-chapter12Android style resource and other resources types-chapter12
Android style resource and other resources types-chapter12
 
mobile application development -unit-3-
mobile application development  -unit-3-mobile application development  -unit-3-
mobile application development -unit-3-
 

More from Sokngim Sa

How to decompile apk
How to decompile apkHow to decompile apk
How to decompile apkSokngim Sa
 
04 activities and activity life cycle
04 activities and activity life cycle04 activities and activity life cycle
04 activities and activity life cycleSokngim Sa
 
02 getting start with android app development
02 getting start with android app development02 getting start with android app development
02 getting start with android app developmentSokngim Sa
 
Add eclipse project with git lab
Add eclipse project with git labAdd eclipse project with git lab
Add eclipse project with git labSokngim Sa
 
Transmitting network data using volley(14 09-16)
Transmitting network data using volley(14 09-16)Transmitting network data using volley(14 09-16)
Transmitting network data using volley(14 09-16)Sokngim Sa
 
C Programming: Control Structure
C Programming: Control StructureC Programming: Control Structure
C Programming: Control StructureSokngim Sa
 

More from Sokngim Sa (8)

06 UI Layout
06 UI Layout06 UI Layout
06 UI Layout
 
How to decompile apk
How to decompile apkHow to decompile apk
How to decompile apk
 
05 intent
05 intent05 intent
05 intent
 
04 activities and activity life cycle
04 activities and activity life cycle04 activities and activity life cycle
04 activities and activity life cycle
 
02 getting start with android app development
02 getting start with android app development02 getting start with android app development
02 getting start with android app development
 
Add eclipse project with git lab
Add eclipse project with git labAdd eclipse project with git lab
Add eclipse project with git lab
 
Transmitting network data using volley(14 09-16)
Transmitting network data using volley(14 09-16)Transmitting network data using volley(14 09-16)
Transmitting network data using volley(14 09-16)
 
C Programming: Control Structure
C Programming: Control StructureC Programming: Control Structure
C Programming: Control Structure
 

Recently uploaded

Gas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxGas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxDr.Ibrahim Hassaan
 
Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaVirag Sontakke
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPCeline George
 
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...JhezDiaz1
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxthorishapillay1
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfUjwalaBharambe
 
Meghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentMeghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentInMediaRes1
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceSamikshaHamane
 
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxRaymartEstabillo3
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
MARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupMARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupJonathanParaisoCruz
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
Final demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxFinal demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxAvyJaneVismanos
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Celine George
 
CELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxCELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxJiesonDelaCerna
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 

Recently uploaded (20)

Gas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxGas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptx
 
Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of India
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERP
 
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
 
9953330565 Low Rate Call Girls In Rohini Delhi NCR
9953330565 Low Rate Call Girls In Rohini  Delhi NCR9953330565 Low Rate Call Girls In Rohini  Delhi NCR
9953330565 Low Rate Call Girls In Rohini Delhi NCR
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptx
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
 
Meghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentMeghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media Component
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in Pharmacovigilance
 
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
MARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupMARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized Group
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
Final demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxFinal demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptx
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17
 
CELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxCELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptx
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 

03 android application structure

  • 3. 3.1. The Android Manifest File
  • 4. 3.1.1 Configuration of your Android Application - The components, settings and metadata, APIs Level and Hardware or software of an Android application are described in the AndroidManifest.xml file. - The manifest is read by the Android system during installation of the application.
  • 6. 3.1.3 Version and Package - The package attribute defines the base package for the Java objects referred to in this file. - Google Play requires that every Android application uses its own unique package name. Therefore it is a good habit to use your reverse domain name here. This will avoid collisions with other Android applications. - android:versionName and android:versionCode specify the version of your application. versionName is what the user sees and can be any string. - versionCode must be an integer. The Android Market determines whether it should perform an update of the applications for the existing installation based
  • 7. 3.1.4 Application and Component - The <application> is a container for declaring other Android components. - The <activity> tag defines an activity. The name attribute points to class, which (if not fully qualified) is relative to the package defined in the`package` attribute. - The intent filter part in the Android manifest file, tells the Android runtime that this activity should be registered as a possible entry point into the application and made available in the launcher of the Android system. The action defines that it ( android:name="android.intent.action.MAIN" ` ) can be started. The `category android:name="android.intent.category.LAUNCHER" parameter tells the Android system to add the activity to the launcher. - The <@string/app_name> value refers to resource files which contain the actual value of the application name. The usage of a resource file makes it easy to provide different resources (e.g., strings, colors, icons) for different devices and makes it easy to translate applications.
  • 8. 3.1.4 Minimum and target SDK minSdkVersion: Define the minimum version of Android your application works on. This attribute is used as a filter in applications stores Play. A user cannot install your application on a device with a lower API level than specified in this attribute. targetSdkVersion: Specifies the version on which you tested and developed. If it is not equal to the API version of the Android device, the Android system might apply forward- or backward-compatibility changes. It is good practice to always set this to the latest Android API version to take advantages of changes in the latest Android improvements.
  • 9. 3.1.5 Permissions - The Android manifest file must also contain the required permissions for the application. For example, if the application requires network access, it must be specified here. - Your application can declare permissions with the <permission> tag and declare that it required a permission with the <uses-permission> tag. - Certain permissions, like network access, are granted automatically on Android 6.0 or higher systems. Other permissions must be confirmed by the users to become active.
  • 10. 3.1.6 Required Device Configuration - The uses-configuration section in the manifest allows you to specify required input methods for your device. For example, the following snippet would require that the device has a hardware keyboard. <uses-configuration android:reqHardKeyboard="true"/> - The uses-feature section allows you to specify the required hardware configuration for your device. For example, the following snippet would require that the device has a camera. <uses-feature android:name="android.hardware.camera" />
  • 12. 3.2.1 Resource Introduction - Externalize Resource has such as image, string, layout,... - There are 2 kind of Resource: Default and Alternative resources. - Example : res/layout vs res/layout-land - Externalize Resource allows alternative resource that support specific device configurations such as different languages or screen sizes. - At runtime, Android uses the appropriate resource based on the current configuration.
  • 13. 3.2.2 Resource Type Directory Resource Type animator/ XML files that define property animations. anim/ XML files that define tween animations. (Property animations can also be saved in this directory, but the animator/ directory is preferred for property animations to distinguish between the two types.) color/ XML files that define a state list of colors drawable/ Bitmap files (.png, .9.png, .jpg, .gif) or XML files that are compiled into the following drawable resource subtypes: Bitmap files, Nine-Patches (re-sizable bitmaps), State lists, Shapes, Animation drawables, Other drawables mipmap/ Drawable files for different launcher icon densities. layout/ XML files that define a user interface layout
  • 14. Directory Resource Type menu/ XML files that define application menus, such as an Options Menu, Context Menu, or Sub Menu raw/ Arbitrary files to save in their raw form. To open these resources with a raw InputStream, call Resources.openRawResource() with the resource ID, which is R.raw.filename. However, if you need access to original file names and file hierarchy, you might consider saving some resources in the assets/ directory (instead of res/raw/). Files in assets/ are not given a resource ID, so you can read them only using AssetManager. values/ XML files that contain simple values, such as strings, integers, and colors. arrays.xml for resource arrays (typed arrays). colors.xml for color values dimens.xml for dimension values. strings.xml for string values. styles.xml for styles. xml/ Arbitrary XML files that can be read at runtime by calling Resources.getXML(). Various XML configuration files must be saved here, such as a searchable configuration. font/ Font files with extensions such as .ttf, .otf, or .ttc, or XML files that include a <font-family> element. For more information about fonts as resources, go to Fonts in XML.
  • 15. 3.2.3 Alternative Resource - Alternative Resource - <resources_name>-<config_qualifier>. - <resources_name> is the directory name of the corresponding default resources (defined in table 1). - <qualifier> is a name that specifies an individual configuration for which these resources are to be used (defined in table 2) - Example res/ drawable/ icon.png background.png drawable-hdpi/ icon.png Background.png - Details - https://developer.android.com/guide/topics/resources/providing- resources.html#ResourceTypes
  • 16. 3.2.4 Resource Accessing - There are two ways to access a resource: - In code: Using a static integer from a sub-class of your R class, such as: ● R.string.hello ● string is the resource type and hello is the resource name. There are many Android APIs that can access your resources when you provide a resource ID in this format. - In XML: Using a special XML syntax that also corresponds to the resource ID defined in your R class, such as: ● @string/hello ● string is the resource type and hello is the resource name. You can use this syntax in an XML resource any place where a value is expected that you provide in a resource. <?xml version="1.0" encoding="utf-8"?> <resources> <color name="opaque_red">#f00</color> <string name="hello">Hello!</string> </resources> res/values/string.xml
  • 18. 3.3.1 Asset Introduction - assets/ directory (instead of res/raw/). - Files in assets/ are not given a resource ID, so you can read them only using AssetManager.
  • 19. Example of Using Assets Java code: WebView wv = (WebView)this.findViewById(R.id.splashWebView); wv.setWebViewClient(new WebViewClient() { @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { view.loadUrl(url); return true; } }); wv.loadUrl("file:///android_asset/html_no_copy/demo_welcome.html");
  • 20. demo_welcome.html: <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <title>Demo Html</title> <link rel="stylesheet" type="text/css" href="demo.css" /> </head> <body> <H1>Testing One Two Three</H1> <a href="test.html">CLICK HERE</a><p> <a href="file:///android_asset/html_no_copy/test.html">OR HERE</a> </body> </html> test.html: <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <link rel="stylesheet" type="text/css" href="test.css" /> <title>Insert title here</title> </head> <body> <H1>TEST.HTML</H1> </body> </html>

Editor's Notes

  1. https://developer.android.com/guide/topics/resources/providing-resources.html#ResourceTypes
  2. https://developer.android.com/guide/topics/resources/providing-resources.html#ResourceTypes
  3. https://developer.android.com/guide/topics/resources/accessing-resources.html