QB Mod 1

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

Mobile Application Development

6th Semester Software Engineering


Module 1: Introduction to Android and Android Studio
1. Explain Android Studio project folder structure.
Ans: Android Studio is the official IDE (Integrated Development Environment) developed
by the JetBrains community which is freely provided by Google for android app
development. After completing the setup of Android Architecture, we can create an android
application in the studio. We need to create a new project for each sample application.

The android project contains different types of app modules, source code files, and resource
files. We will explore all the folders and files in the android app.
1. Manifests
2. Java Folder
3. res (Resources) Folder
 Drawable Folder
 Layout Folder
 menu
 Mipmap Folder
 Values Folder
4. Gradle Scripts

Manifests
The Android manifest file helps to declare the permissions that an app must have to access
data from other apps. The Android manifest file also specifies the app’s package name that
helps the Android SDK while building the app. The Android manifest file provides
information such as activities, services, broadcast receivers, and content providers of an
android application.

Java folder
The Java folder contains all the java and Kotlin source code (.java) files that we create
during the app development, including other Test files. If we create any new project using
Kotlin, by default the class file MainActivity.kt file will create automatically under the
package name
Resource (res) folder
The resource folder is the most important folder because it contains all the non-code
sources like images, XML layouts, and UI strings for our android application.
res/drawable folder
It contains the different types of images used for the development of the application. We
need to add all the images in a drawable folder for the application development.

res/layout folder
The 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.
res/menu
The XML file related to the design of the menu elements will be placed in this folder.
Using inflate object the menu design in this folder will be attached to UI component.

res/mipmap folder
This folder contains launcher.xml files to define icons that are used to show on the home
screen. It contains different density types of icons depending upon the size of the device
such as hdpi, mdpi, xhdpi.

res/values folder
Values folder contains a number of XML files like strings, dimensions, colors, and style
definitions. One of the most important files is the strings.xml file which contains the
resources.
These folders are available with respect to res folder by default. Based on requirement few
more folders will be added.

Gradle Scripts folder


Gradle means automated build system and it contains a number of files that are used to
define a build configuration that can be applied to all modules in our application. In
build.gradle (Project) there are build scripts and in build.gradle (Module) plugins and
implementations are used to build configurations that can be applied to all our application
modules.

2. An android device will consist of many inbuilt system applications, if the


requirement is to open the telephone number clicked, in a system default dialler
pad. Which object to be configured? Explain in detail.
Ans: Intent objects are used to navigate from one activity to another activity. If the
navigation is between the activities of same application, then it is called Explicit Intent and if
you are open opening some content in system specified default app then it is called Implicit
intent. According to the requirement given in the question statement. We have to use implicit
intents, the following steps to be followed to work with implicit intents.
a. Prepare URI object: Identify the data being addressed by using the suitable
keyword. Ex: “tel:” for phone number, “ http:// “ for web page and “geo: “ for
map data (longitude and latitude).
b. Create the intent object by passing two arguments. 1st argument shows the
action to be performed and 2nd argument will be URI object created in previous
step.
c. Call startActivity function and pass the intent object created.
Ex: For opening a number in dialler pad the code snippets is as follows:
Uri uri = Uri.parse("tel:8005551234");
Intent it = new Intent(Intent.ACTION_DIAL, uri);
startActivity(it);
Consider an Activity as shown, the method ImpIntent will implement the
implicit intent and open the number given in dialler pad on click.

public void ImpIntent(View view) {


Uri uri=Uri.parse("tel:8005551234");
Intent intent=new Intent(Intent.ACTION_DIAL,uri);
startActivity(intent);
Toast.makeText(this, "This is from ImpIntent method",
Toast.LENGTH_LONG).show();
Log.d("App", "ImpIntent: For Check... ");
}

3. Explain android Activity Lifecycle.


Ans: An activity in android has its own life cycle with various methods and stages. The
following diagram gives the life cycle of android.

1. onCreate()
It is called when the activity is first created. This is where all the static work is done like
creating views, binding data to lists, etc. This method also provides a Bundle containing its
previous frozen state, if there was one.
2. onStart()
It is invoked when the activity is visible to the user. It is followed by onResume() if the
activity is invoked from the background. It is also invoked after onCreate() when the
activity is first started.
3. onRestart()
It is invoked after the activity has been stopped and prior to its starting stage and thus is
always followed by onStart() when any activity is revived from background to on-screen.
4. onResume()
It is invoked when the activity starts interacting with the user. At this point, the activity is
at the top of the activity stack, with a user interacting with it. Always followed by
onPause() when the activity goes into the background or is closed by the user.
5. onPause()
It is invoked when an activity is going into the background but has not yet been killed. It is
a counterpart to onResume(). When an activity is launched in front of another activity, this
callback will be invoked on the top activity (currently on screen). The activity, under the
active activity, will not be created until the active activity’s onPause() returns, so it is
recommended that heavy processing should not be done in this part.
6. onStop()
It is invoked when the activity is not visible to the user. It is followed by onRestart() when
the activity is revoked from the background, followed by onDestroy() when the activity is
closed or finished, and nothing when the activity remains on the background only.
Note: this method may never be called, in low memory situations where the system does
not have enough memory to keep the activity’s process running after its onPause() method
is called

7. onDestroy()
The final call received before the activity is destroyed. This can happen either because the
activity is finishing (when finish() is invoked) or because the system is temporarily
destroying this instance of the activity to save space.

4. Design a Login activity using Linear Layout (Same question can be asked using
relative layout also)

5. Bring out the differences between Relative and Constraint Layout.


6. Write a short note on:
a. R.java file
b. Android.manifest
7. Bring out the differences between Relative and Constraint Layout.

You might also like