Android
1. Attempt any FIVE of the following: 10
a) List any four features of Android operating system.
- Open Source
- Beautiul UI
- Connectivity
- Storage
- Multi-Touch
- Multi-Tasking
- Multi-Language
- Resizable widgets
- Messaging
- Media Support
- Web Browser
b) Define Dalvik Virtual Machine (DVM).
JVM | DVM |
---|---|
JVM supports multiple OS | DVM supports only Android Operating system. |
JVM forms separate classes in separate .class byte code files. |
DVM forms multiple class in .dex byte code file. |
It is based on stack based virtual machine architecture. | It is based on register based virtual machine architecture. |
JVM runs on more memory | DVM runs on less memory. |
The executable format of JVM is JAR. | The executable format of DVM is APK. |
JVM has different constant pools. | DVM has common constant pool. |
It runs .class byte code directly. |
The .class byte codes are optimize to .odex format before executing in DVM. |
c) List any four folders from directory structure of Android project and elaborate in one line.
Manifests Folder
- Manifests folder contains AndroidManifest.xml for creating our android application.
- This file contains information about our application such as the Android version, metadata, states package for Kotlin file, and other application components.
It acts as an intermediator between android OS and our 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.
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.
d) List any four attributes of check box.
- text - This is the Text to display.
- id - This supplies an identifier name for this view.
- visibility - This controls the initial visibility of the view.
- editable - If set, specifies that this TextView has an input method.
f) State syntax to display built in zoom control.
In Android, Zoom Control is a class that has some set of methods that are used to control the zoom functionality.
ZoomControl zoomControls = (ZoomControls) findViewById(R.id.simpleZoomControl);
g) Name two classes used to play audio and video in Android.
- The following classes are used to play sound and video in the Android framework:
- MediaPlayer - This class is the primary API for playing sound and video.
- AudioManager - This class manages audio sources and audio output on a device.
2. Attempt any THREE of the following: 12
a) Describe Android architecture with diagram.
- Android architecture contains different number of components to support any android device needs. Android software contains an open-source Linux Kernel having collection of number of C/C++ libraries which are exposed through an application framework services.
- The main components of android architecture are following:
- Applications: Applications is the top layer of android architecture. The pre-installed applications like home, contacts, camera, etc and third party applications will be installed on this layer only.
- Application framework: Application Framework provides several important classes which are used to create an Android application.
- Application runtime: Android Runtime environment contains components like core libraries and the Dalvik virtual machine(DVM).
- Platform libraries: The Platform Libraries includes various C/C++ core libraries and Java based libraries such as Media, Graphics, OpenGL etc. to provide a support for android development.
- Linux Kernel: The linux kernel manages all the available drivers such as display drivers, camera drivers, audio drivers, etc. which are required during the runtime.
b) Differentiate between DVM and JVM
JVM | DVM |
---|---|
JVM supports multiple OS | DVM supports only Android Operating system. |
JVM forms separate classes in separate .class byte code files. |
DVM forms multiple class in .dex byte code file. |
It is based on stack based virtual machine architecture. | It is based on register based virtual machine architecture. |
JVM runs on more memory | DVM runs on less memory. |
The executable format of JVM is JAR. | The executable format of DVM is APK. |
JVM has different constant pools. | DVM has common constant pool. |
It runs .class byte code directly. |
The .class byte codes are optimize to .odex format before executing in DVM. |
c) List and elaborate steps to deploy in Android application on Google play store.
- Step 1 - First generate signed apk of your Android App to publish it on Play Store.
- Step 2 - Sign up for Google Play Console to publish and manage your Android App.
- Step 3 - Now click on Create Application.
- Step 4 - Now fill store listing details of your App which include Title, Short and Full description.
- Step 5 - Now Click on ready on publish along with save draft and click on Manage release.
- Step 6 - After Manage production click on edit release.
- Step 7 - Now click on review.
- Step 8 - After review click on Start Rollout to production.
d) Describe with example, how to create a simple database in SQLite (Assume suitable data).
- SQLite is a opensource SQL database that stores data to a text file on a device. Android comes in with built in SQLite database implementation.
SQLite supports all the relational database features.
.javaSQLiteDatabase mydatabase = openOrCreateDatabase("your database name",MODE_PRIVATE,null);
3. Attempt any THREE of the following: 12
a) Write down the steps to install and configure Android studio.
- Head over to https://developer.android.com/studio to get the Android Studio executable or zip file.
- Click on the Download Android Studio Button.
- After the downloading has finished, open the file from downloads and run it. It will prompt the following dialog box.
- Once βFinishβ is clicked, choose the βDonβt import Settings optionβ.
- This will start the Android Studio.
- After it has found the SDK components, it will redirect to the Welcome dialog box.
- Now it is time to download the SDK components.
- Click on Start a new Android Studio project to build a new app.
b) State syntax to create Text View and Image button with any two attributes of each.
TextView
<TextView
android:id="@+id/student_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Name:" />
- text - Sets text of the Textview
- id - Gives a unique ID to the Textview
ImageButton
<ImageButton
android:id="@+id/imageButton"
android:src="@drawable/button"
android:layout_height="wrap_content"
android:layout_width="wrap_content"/>
- background - This is a drawable to use as the background.
- id - Gives a unique ID to the Textview
c) Describe Android service life cycle along with diagram.
- A service is an application component which runs withour direst interaction with the user in the background.
- Services are used for repetitive and potentially long running operations:
- Internet downloads
- Checking for new data
- Data processing
- Updating content
- Providers and the like
They typically run in the background to perform long-running operations or work for remote processes.
ββ¬βββββββββ¬β ββActivityββ ββlaunchedββ ββ΄βββββ¬ββββ΄β β ββββββΌββββββ ββββββββββββββββββββββΊonCreate()β β ββββββ¬ββββββ β β β ββββββΌβββββ βββββββββββββ β βonStart()ββββββββββββββββββββββ€onRestart()β β ββββββ¬βββββ βββββββββ²ββββ β β β User navigates ββββββΌββββββ β to the activity βonResume()βββββββββββββββββ β β ββββββ¬ββββββ β β β β β β ββ¬ββββββ΄ββββββ¬β ββ¬βββββ΄ββββ¬β β β ββApp processββ ββActivityββ β β ββkilled ββ ββRunning ββ β β ββ΄ββββββ²ββββββ΄β ββ΄βββββ¬ββββ΄β β β β β β β β βΌ β β Apps with higher priority Another activity comes User returns β need memory into the foreground to the activity β β β β β β β β β β ββββββΌβββββ β β β βonPause()ββββββββββββββββββ β β ββββββ¬βββββ β β β β β β β β The activity is β β no longer visible β β β User navigates β β to the activity β ββββββΌββββ β ββββββββββββββββββββββ€onStop()βββββββββββββββββββββββββββββββ ββββββ¬ββββ β β The activity is finishing or being destroyed by the system β β ββββββΌβββββββ βonDestroy()β ββββββ¬βββββββ β ββ¬βββββΌβββββ¬β ββActivity ββ ββShut Downββ ββ΄ββββββββββ΄β
d) State and elaborate the syntax of required class and methods for Geocoding.
- A class for handling geocoding and reverse geocoding.
Geocoding is the process of transforming a street address or other description of a location into a (latitude, longitude) coordinate.
.javapublic final class Geocoder extends Object
4. Attempt any THREE of the following: 12
a) Explain with example, code to create GUI using absolute layout (Assume suitable data).
<?xml version="1.0" encoding="utf-8"?>
<AbsoluteLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="16dp"
android:paddingTop="16dp"
android:paddingRight="16dp"
tools:context=".MainActivity">
<TextView
android:id="@+id/student_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="125dp"
android:layout_y="280dp"
android:text="Name:"
android:textColor="#86AD33"
android:textSize="20dp"
android:textStyle="bold" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="125dp"
android:layout_y="304dp"
android:text="Age:"
android:textColor="#86AD33"
android:textSize="20dp"
android:textStyle="bold" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="125dp"
android:layout_y="328dp"
android:text="Mobile Number:"
android:textColor="#86AD33"
android:textSize="20dp"
android:textStyle="bold" />
</AbsoluteLayout>
b) Write a program to demonstrate Date and Time picker.
Date Picker
- Android Date Picker allows you to select the date consisting of day, month and year in your custom user interface.
- Methods of DatePicker:
- getDayOfMonth() - This method gets the selected day of month.
- getMonth() - This method gets the selected month.
- getYear() - This method gets the selected year.
- getFirstDayOfWeek() - This method returns first day of the week.
- getCalendarView() - This method returns calender View.
TimePicker
- Android Time Picker allows us to select the time of day in either 24h or AM/PM mode.
- The time consists of hours, minutes and clock format.
- Methods of TimePicker
- setCurrentHour() - This method sets the current hour.
- setCurrentMinute() - This method sets the current minute.
- is24HoursView() - This method returns true if this 24 hour view else false.
- isEnabled() - This method returns the enabled status for this view.
c) Describe multimedia framework of Android with diagram.
d) Discuss developer console with at least four features.
- Multiple User Accounts
- Store Listing Details
- Upload and Instantly Publish
- Alpha and Beta Testing
- Multiple APK Support
- Selling and Pricing Your Products
- In-app Products
- Distribution Controls
- User Reviews and Crash Reports
- App Statistics
e) Write a program to demonstrate declaring and using permissions with any relevant example.
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.geeksforgeeks.requestPermission">
<!--Declaring the required permissions-->
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.CAMERA" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity
android:name=".MainActivity">
<intent-filter>
<action
android:name="android.intent.action.MAIN" />
<category
android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<!-- To show toolbar-->
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:background="@color/colorPrimary"
app:title="GFG | Permission Example"
app:titleTextColor="@android:color/white"
android:layout_height="?android:attr/actionBarSize"/>
<!--Button to request storage permission-->
<Button
android:id="@+id/storage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Storage"
android:layout_marginTop="16dp"
android:padding="8dp"
android:layout_below="@id/toolbar"
android:layout_centerHorizontal="true"/>
<!--Button to request camera permission-->
<Button
android:id="@+id/camera"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Camera"
android:layout_marginTop="16dp"
android:padding="8dp"
android:layout_below="@id/storage"
android:layout_centerHorizontal="true"/>
</RelativeLayout>
MainActivity.java
import android.Manifest;
import android.content.pm.PackageManager;
import android.support.annotation.NonNull;
import android.support.v4.app.ActivityCompat;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;
public class MainActivity extends AppCompatActivity {
// Defining Buttons
private Button storage, camera;
// Defining Permission codes.
// We can give any value
// but unique for each permission.
private static final int CAMERA_PERMISSION_CODE = 100;
private static final int STORAGE_PERMISSION_CODE = 101;
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
storage = findViewById(R.id.storage);
camera = findViewById(R.id.camera);
// Set Buttons on Click Listeners
storage.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v)
{
checkPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE, STORAGE_PERMISSION_CODE);
}
});
camera.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v)
{
checkPermission(Manifest.permission.CAMERA, CAMERA_PERMISSION_CODE);
}
});
}
// Function to check and request permission.
public void checkPermission(String permission, int requestCode)
{
if (ContextCompat.checkSelfPermission(MainActivity.this, permission) == PackageManager.PERMISSION_DENIED) {
// Requesting the permission
ActivityCompat.requestPermissions(MainActivity.this, new String[] { permission }, requestCode);
}
else {
Toast.makeText(MainActivity.this, "Permission already granted", Toast.LENGTH_SHORT).show();
}
}
// This function is called when the user accepts or decline the permission.
// Request Code is used to check which permission called this function.
// This request code is provided when the user is prompt for permission.
@Override
public void onRequestPermissionsResult(int requestCode,
@NonNull String[] permissions,
@NonNull int[] grantResults)
{
super.onRequestPermissionsResult(requestCode,
permissions,
grantResults);
if (requestCode == CAMERA_PERMISSION_CODE) {
if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
Toast.makeText(MainActivity.this, "Camera Permission Granted", Toast.LENGTH_SHORT) .show();
}
else {
Toast.makeText(MainActivity.this, "Camera Permission Denied", Toast.LENGTH_SHORT) .show();
}
}
else if (requestCode == STORAGE_PERMISSION_CODE) {
if (grantResults.length > 0
&& grantResults[0] == PackageManager.PERMISSION_GRANTED) {
Toast.makeText(MainActivity.this, "Storage Permission Granted", Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(MainActivity.this, "Storage Permission Denied", Toast.LENGTH_SHORT).show();
}
}
}
}
Android
1. What is Mobile application?
- A mobile application, most commonly referred to as an app, is a type of application software deigned to run on a mobile device, such as a smart phone or tablet computer.
- Mobile app development is the process by which a mobile applications is developed for mobile devices like Personal Digital Assistants (PDAs), tablet computer or mobile smart phones.
- Android is mobile operating system developed by Google, based on a modified version of the Linux kernel and other open source software and designed primarily for touchscreen mobile devices such as smart phones and tablets.
- Application developers, Android is an open platform that provides exciting opportunities for developing virtually app imaginable.
3. What is Android?
- The android is a powerful Operating System(OS) and it supports large numbers of applications(apps) in smart phones.
- The hardware that supports android software is based on ARM architecture platform.
- The android is an open source operating system means that it is free and any one can use it.
- The android development supports with the full Java programming language.
4. Enlist features of Android OS?
- Storage - SQLite a lightweight relational database, is used for data storage purpose.
- Multitasking - Multitasking of application, with unique handling of memory allocation, will be existing.
- Web Browser - The web browser available in Android OS is based on the open source WebKit layout engine, attached with Chrome's V8 JavaScript engine.
- Open Source - Android is open-source operating system.
- Accessibility - Built in text to speech in Android OS is provided by Talk back for people with low or no vision.
- Media Support - Android supports the many media formats like:
- WenM
- H.263
- H.254
- AAC
- HE-AAC
- MPEG-4
5. State Advantages and Disadvantages of Android OS?
Advantages
- Supports 2D and 3D Graphics
- Supports Multiple Languages
- Faster Web Browser
- Video Calling
- Open Source Framework
- Uses of Tools are Very Simple
- Availability of Apps
- Great Social Networking Integration
- Better Notification System
- Update User Interface Design
- At a Time Applications
- Low Chance of Crashing
- Stability
- Multitasking
Disadvantages
- Need Internet Connection
- Advertising
- Wasteful Battery
- Many Applications
- Slow Response
- Heat
6. Describe Architecture of Android diagrammatically.
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Application β
β ββββββ ββββββββββ βββββββ βββββββββ βββββ β
β βHomeβ βContactsβ βPhoneβ βBrowserβ β***β β
β ββββββ ββββββββββ βββββββ βββββββββ βββββ β
β β
β ββββββ ββββββββ βββββββ ββββββββββ βββββ β
β βSMS β βE-Mailβ βClockβ βCalanderβ β***β β
β ββββββ ββββββββ βββββββ ββββββββββ βββββ β
β β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β β
β Application Framework β
β ββββββββββββββββββ ββββββββββββββββ βββββββββββββββββββ βββββββββββββ β
β βActivity Managerβ βWindow Managerβ βContent Providersβ βView Systemβ β
β ββββββββββββββββββ ββββββββββββββββ βββββββββββββββββββ βββββββββββββ β
β β
β βββββββββββββββββ βββββββββββββββββββ ββββββββββββββββββ ββββββββββββββββββ β
β βPackage Managerβ βTelephony Managerβ βResource Managerβ βLocation Managerβ β
β βββββββββββββββββ βββββββββββββββββββ ββββββββββββββββββ ββββββββββββββββββ β
β β
ββββββββββββββββββββββββββββββββββββββββββββββββ¬ββββββββββββββββββββββββββββββββ€
β Libraries β Android Runtime β
β βββββββββββββββββ βββββββββββββββββ ββββββββ β ββββββββββββββββ β
β βSurface Managerβ βMedia Frameworkβ βSQLiteβ β βCore Librariesβ β
β βββββββββββββββββ βββββββββββββββββ ββββββββ β ββββββββββββββββ β
β β β
β βββββββββββ ββββββββββ ββββββββ β ββββββββββββββββββββββββ β
β βOpenGL/ESβ βFreeTypeβ βWebKitβ β βDalvik Virtual Machineβ β
β βββββββββββ ββββββββββ ββββββββ β ββββββββββββββββββββββββ β
β β β
β βββββ βββββ ββββββ β β
β βSGLβ βSSLβ βLibcβ β β
β βββββ βββββ ββββββ β β
β β β
ββββββββββββββββββββββββββββββββββββββββββββββββ΄ββββββββββββββββββββββββββββββββ€
β Linux Kernel β
β ββββββββββββββββ βββββββββββββββ βββββββββββββββββββββ βββββββββββββββββββββ β
β βDisplay Driverβ βCamera Driverβ βFlash Memory Driverβ βBinder (IPC) Driverβ β
β ββββββββββββββββ βββββββββββββββ βββββββββββββββββββββ βββββββββββββββββββββ β
β β
β βββββββββββββββ βββββββββββββ ββββββββββββββ ββββββββββββββββββ β
β βKeypad Driverβ βWiFi Driverβ βAudio Driverβ βPower Managementβ β
β βββββββββββββββ βββββββββββββ ββββββββββββββ ββββββββββββββββββ β
β β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
7. What is OHA?
- The OHA stands for Open Hardware Alliance.
- Google formed OHA in order to develop an open source software platform for use in mobile devices.
- The OHA is the group that is in charge of the Android smart phones OS.
- The primary objective of these companies is to developed open standards for mobile devices.
- The members of OHA include handset manufactures, chip makers, commercialization companies, software companies and mobile operators/users.
8. Explain the term Android ecosystem in detail.
- The learn about Android Operating system and develop Android application, it is very important for to understand the entire ecosystem of Android and the stakeholders of Android ecosystem.
- The four parts of Android Ecosystem:
- Google - develops android.
- OEMs (Original Equipment Manufactures) manufacture the hardware, and as well the custom application components.
- Application Development Companies - are the major contactors to the ecosystem and employ developers, and also contract out the product development to services companies.
- Freelance Android Developers have the skill-set to contribute to the ecosystem for android development, they are who create their own applications and publish them on Google Play Store.
9. What are the features of Android? Enlist any six of them.
- Storage - SQLite a lightweight relational database, is used for data storage purpose.
- Multitasking - Multitasking of application, with unique handling of memory allocation, will be existing.
- Web Browser - The web browser available in Android OS is based on the open source WebKit layout engine, attached with Chrome's V8 JavaScript engine.
- Open Source - Android is open-source operating system.
- Accessibility - Built in text to speech in Android OS is provided by Talk back for people with low or no vision.
- Media Support - Android supports the many media formats like:
- WenM
- H.263
- H.254
- AAC
- HE-AAC
- MPEG-4
10. Explain the term Android ecosystem in detail.
- Android 13
- Android 12
- Android 11
- Android 10
- Android Pie
- Android Oreo
- Android Nougat
- Android Marshmallow
- Android Lollipop
- Android KitKat
- Android Jelly Bean
- Android Sandwich
- Android Honeycomb
- Android Gingerbread
- Android Froyo
- Android Eclair
- Android Donut
- Android 1.5
- Android 1.1
- Android 1.0
11. Explain the need of Android.
- Desktop -Android-x86 is an open source project that ports Android to the x86 platform, allowing you to run it on your computer instead of an ARM-based phone or tablet.
- Connectivity - On one page/desktop we could be able to have four connecting device tool button like, Turn ON/OFF Bluetooth, Turn ON/OFF WiFi, Turn ON/OFF mobile network, Turn ON/OFF GPS and so on.
- Browser - The Android OS browser is one of the best browser on the mobile market. It generally loads pages faster then Safari or any other browser.
- Open to carrier - If we know Java programming language then we are open to Android world.
- Market - Android OS has an android market. The android apps are free and work as well.
- Future - The future mobile phones are basically going to be smartphones.
- Notification - Android phones have multi notification system.
- Google Integration - The android has inbuilt Google support. For example: Google Map, G-Mail etc.
- Open Source - The code of Android OS as well as the apps is available.
- Endless Personalization - The Android cell phone allow to configuration their mobile to look and behave exactly like they want.
14. Explain the following terms:
(i) Android application
- The top layer of Android architecture is Applications.
- The native and third party applications like Contacts, Email, Music, Gallery, Clock, Games, etc.
- Whatever we will build those will be installed on this layer only.
- The application layer runs within the Android run time using the classes an services made available from the application framework.
(ii) Android kernel
- Linux kernel is a bottom layer and heart of the android architecture.
- It exists at the root of android architecture and contains all the low-level device drivers fro the various hardware components of an Android device.
- Linux Kernel is responsible for device drivers, power management, memory management, device management and resource access.
16. Describe OHA with the Help of Digram.
βββββββββββ βββββββββββ ββββββββββββββ ββββββββ βββββββββββββββββ
βSoftware β βMobile β βHandset β βChip β βCommercializtonβ
βCompaniesβ βOperatorsβ βManufacturesβ βMakersβ βCompanies β
βββββββ¬ββββ βββββββ¬ββββ βββββββ¬βββββββ βββββ¬βββ ββββββββββ¬βββββββ
β β β β β
βββββββββββββ΄ββββββββββββΌβββββββββββββ΄ββββββββββββββ
β
ββββββββ΄ββββββββ
βOpen Handset β
βAlliance (OHA)β
ββββββββββββββββ
17. Enlist and explain any 4 features of Android.
- Storage - SQLite a lightweight relational database, is used for data storage purpose.
- Multitasking - Multitasking of application, with unique handling of memory allocation, will be existing.
- Web Browser - The web browser available in Android OS is based on the open source WebKit layout engine, attached with Chrome's V8 JavaScript engine.
- Open Source - Android is open-source operating system.
19. Explain the concept of Android Ecosystem.
- The learn about Android Operating system and develop Android application, it is very important for to understand the entire ecosystem of Android and the stakeholders of Android ecosystem.
- The four parts of Android Ecosystem:
- Google - develops android.
- OEMs (Original Equipment Manufactures) manufacture the hardware, and as well the custom application components.
- Application Development Companies - are the major contactors to the ecosystem and employ developers, and also contract out the product development to services companies.
- Freelance Android Developers have the skill-set to contribute to the ecosystem for android development, they are who create their own applications and publish them on Google Play Store.
20. Explain any 4 advantages and disadvantages of Android OS.
Advantages
- Supports 2D and 3D Graphics
- Supports Multiple Languages
- Faster Web Browser
- Video Calling
- Open Source Framework
- Uses of Tools are Very Simple
- Availability of Apps
- Great Social Networking Integration
- Better Notification System
- Update User Interface Design
- At a Time Applications
- Low Chance of Crashing
- Stability
- Multitasking
Disadvantages
- Need Internet Connection
- Advertising
- Wasteful Battery
- Many Applications
- Slow Response
- Heat
21. Describe the concept of Anatomy of Android Application.
java
- This contains the.java
source filed for our project. By default, includes anMainActivity.java
source file having an activity class that runs when our app is launched using the app icon.res/drawable-hdpi
- This is directory for drawable objects that are designed for high-density screens.res/layout
- This is a directory for other various XML files that contain a collection of resources, such as strings and colours definitions.AndroidManifest.xml
- This is the manifest file which describes the fundamental characteristics of the app and defines each of its components.Build.gradle
- This is an auto generated file which containscompileSdkVersion
,buildToolsVersion
,applicationId
,minSdkVersion
,targetSdkVersion
,versionCode
andversionName
.
22. Draw and explain the architecture of Android.
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Application β
β ββββββ ββββββββββ βββββββ βββββββββ βββββ β
β βHomeβ βContactsβ βPhoneβ βBrowserβ β***β β
β ββββββ ββββββββββ βββββββ βββββββββ βββββ β
β β
β ββββββ ββββββββ βββββββ ββββββββββ βββββ β
β βSMS β βE-Mailβ βClockβ βCalanderβ β***β β
β ββββββ ββββββββ βββββββ ββββββββββ βββββ β
β β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β β
β Application Framework β
β ββββββββββββββββββ ββββββββββββββββ βββββββββββββββββββ βββββββββββββ β
β βActivity Managerβ βWindow Managerβ βContent Providersβ βView Systemβ β
β ββββββββββββββββββ ββββββββββββββββ βββββββββββββββββββ βββββββββββββ β
β β
β βββββββββββββββββ βββββββββββββββββββ ββββββββββββββββββ ββββββββββββββββββ β
β βPackage Managerβ βTelephony Managerβ βResource Managerβ βLocation Managerβ β
β βββββββββββββββββ βββββββββββββββββββ ββββββββββββββββββ ββββββββββββββββββ β
β β
ββββββββββββββββββββββββββββββββββββββββββββββββ¬ββββββββββββββββββββββββββββββββ€
β Libraries β Android Runtime β
β βββββββββββββββββ βββββββββββββββββ ββββββββ β ββββββββββββββββ β
β βSurface Managerβ βMedia Frameworkβ βSQLiteβ β βCore Librariesβ β
β βββββββββββββββββ βββββββββββββββββ ββββββββ β ββββββββββββββββ β
β β β
β βββββββββββ ββββββββββ ββββββββ β ββββββββββββββββββββββββ β
β βOpenGL/ESβ βFreeTypeβ βWebKitβ β βDalvik Virtual Machineβ β
β βββββββββββ ββββββββββ ββββββββ β ββββββββββββββββββββββββ β
β β β
β βββββ βββββ ββββββ β β
β βSGLβ βSSLβ βLibcβ β β
β βββββ βββββ ββββββ β β
β β β
ββββββββββββββββββββββββββββββββββββββββββββββββ΄ββββββββββββββββββββββββββββββββ€
β Linux Kernel β
β ββββββββββββββββ βββββββββββββββ βββββββββββββββββββββ βββββββββββββββββββββ β
β βDisplay Driverβ βCamera Driverβ βFlash Memory Driverβ βBinder (IPC) Driverβ β
β ββββββββββββββββ βββββββββββββββ βββββββββββββββββββββ βββββββββββββββββββββ β
β β
β βββββββββββββββ βββββββββββββ ββββββββββββββ ββββββββββββββββββ β
β βKeypad Driverβ βWiFi Driverβ βAudio Driverβ βPower Managementβ β
β βββββββββββββββ βββββββββββββ ββββββββββββββ ββββββββββββββββββ β
β β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
- The main components of Android architecture are:
- Application
- Android Framework
- Android Runtime
- Platform Libraries
- Linux Kernel
Application
- The top layer of Android architecture is Applications.
- The native and third party applications like Contacts, Email, Music, Gallery, Clock, Games, etc.
- Whatever we will build those will be installed on this layer only.
- The application layer runs within the Android run time using the classes an services made available from the application framework.
Application Framework
- The Application framework provides the classes used to create an Android application.
- It also provides a generic abstraction for hardware access and manages the user interface and application resources.
- It basically provides the services through which we can create the particular class and make that class helpful for Application creation.
- The application framework includes services like telephony service, location services, notification manager, NFC service, View system, etc.
- Which can use for application development as per our requirements.
Android Runtime
- Android Runtime environment is an important part of Android rather then an internal part and it contains a components like core libraries and the Dalvik Virtual Machine(DVM).
- The Android run time is the engine that powers our applications along with the
libraries and it forms the basis for the application framework.
- Dalvik Virtual Machine(DVM) - is register-based virtual machine like Java Virtual Machine(JVM). It is specially designed and optimized for Android to ensure that a device can run multiple instance efficiently.
- The core libraries in Android runtime will enable is to implement an Android applications using standard Java programming language.
Platform Libraries
- The Platform Libraries includes various C/C++ core libraries and Java based libraries such as SSL, libc,Graphics, SQLite, WebKit, Media, Surface Manger, OpenGL etc.
Linux Kernel
- Linux kernel is a bottom layer and heart of the android architecture.
- It exists at the root of android architecture and contains all the low-level device drivers fro the various hardware components of an Android device.
- Linux Kernel is responsible for device drivers, power management, memory management, device management and resource access.
Android Application Components
- Activates - They dictate the UI and handle the user interaction to the smart phone screen.
- Services - They handle background processing associated with an application.
- Broadcast Receivers - They handle communication between Android OS and applications.
- Content Provides - They handle data and database management issues.
- Fragments - Represents a portion of user interface in an Activity.
- Views - UI elements that are drawn on-screen including buttons, lists forms etc.
- Layouts - View hierarchies that control screen format and appearance of the views.
- Intents -Messages wiring components together.
- Resources - External elements, such as strings, constants and drawable pictures.
- Manifest - Configuration file for the application.
2. Installing and Configuration of Android
1. What is OS? Explain OS requirements for Android.
- To develop an Android program, the necessary supporting OS used in a computer
can be follows:
- Windows XP, Vista, 7, 8
- Mac OS x
- Linux
2. What is JDK?
- An Android operating system program is developed in Java programming language we have to install Java Development Kit (JDK) in computer.
3. What is SDK?
- API libraries, and emulator, documentation, sample code, developer tools, and tutorials which help us to build, test and debug apps form Android.
- Android SDK is made up of two main parts namely, the tools and the packages.
- Some Android SDK, features include:
- No licensing, distribution, or development fees.
- WiFi hardware access
- IPC message passing
- Shared data stores
- An integrated open source WebKit-based browser.
- Full support for application that integrate Map controls as part of their interface.
- Peer-to-Peer(P2P) support using Google Talk.
5. Describe DVM with diagram.
βββββββββββββ
βββββββββββββ¬βββββββββββ¬ββββββ€Android SDKββββββββββββ¬ββββββββββββ
β β β βββββββ¬ββββββ β β
β β β β β β
βββββ΄βββββ ββββββ΄βββββ βββββ΄βββββ ββββββ΄βββββββββ βββββββ΄ββββββ βββββ΄ββββββ
βDebuggerβ βLibrariesβ βEmulatorβ βDocumentationβ βSample Codeβ βTutorialsβ
ββββββββββ βββββββββββ ββββββββββ βββββββββββββββ βββββββββββββ βββββββββββ
What is JVM? Compare JVM and DVM?
- Dalvik is register-based Virtual Machine(VM) that's been optimized to ensure that a device can run multiple instance efficiently.
- Dalvik VM takes the generated Java class files and combines them into one or
more Dalvik Executable (
.dev
) files. - Android OS uses the Dalvik Virtual Machine (DVM) with just-during-time compilation to run Dalvik bytecode, with is frequently translated from Java bytecode.
- Google has also fine-tuned the collection in the Dalvik VM, but it has chosen to remove Just-In-Time (JIT) compiler, in early releases.
- Dalvik VM use a different kind of assembly-code generation, in which it uses registers as the primary units of data storage instead of the stack.
JVM | DVM |
---|---|
JVM supports multiple OS | DVM supports only Android OS |
JVM forms separate classes in separate .class byte code files. |
DVM forms multiple class .dex byte code file. |
It is based on stack based VM architecture. | It is based on register based VM architecture. |
JVM runs on more memory. | DVM runs on less memory. |
The executable format of JVM is JAR. | The executable format of DVM is APK. |
JVM has different content pools. | DVM has common constant pool. |
It runs .class byte code directly. |
The .class byte codes are optimized to .odex format before executing in DVM. |
7. Explain the term emulator in detail.
- Android Emulator is responsible for running, debugging and testing the Android application.
- The Android Emulator mimics all the hardware and software features of typical mobile devices except that it can't place annual phone calls.
8. What is ADT? Describe in detail.
- Android Development Tool (ADT) in Android is a plugin for the Eclipse IDE which provides a suitable environment to develop an Android application where creation, compilation and debugging are possible.
10. Differentiate between JDK and SDK.
SDK | JDK |
---|---|
Software development kit. | Java development kit. |
It is a set of software or development tools used to create an application or a program on any platform. | It is a set of development tools that allows a programmer write a program using Java language. |
Libraries, sample code, supporting documentation etc. | Consists of the programming tool's selection components. |
Android SDK | Java 8, Java 11, etc. |
11. Define the terms: JDK, SDK, AVD, ADT
- JDK - An Android operating system program is developed in Java programming language we have to install Java Development Kit (JDK) in computer.
- SDK - API libraries, and emulator, documentation, sample code, developer tools, and tutorials which help us to build, test and debug apps form Android.
- AVD - And Android Virtual Device (AVD) represents a device configuration.
- ADT - Android Development Tool (ADT) in Android is a plugin for the Eclipse IDE which provides a suitable environment to develop an Android application where creation, compilation and debugging are possible.
Explain AVD in detail.
- And Android Virtual Device(AVD) represents a device configuration.
- An AVD is a configuration that defines the characteristics of an Android phone , tablet, Wear OS, Android TV, or Automotive OS device that we want to simulate in the Android Emulator.
- An AVD contains:
- Hardware profile - The hardware profile defines the characteristics of a device as shipped from the factory.
- System image - A system image labeled with Google APIs includes access to Google Play services.
- Storage area - The AVD has dedicated storage area on our development machine.
- Skin - An emulator skin specifics the appearance of a device.
18. Differentiate between JVM and DVM.
JVM | DVM |
---|---|
JVM supports multiple OS | DVM supports only Android OS |
JVM forms separate classes in separate .class byte code files. |
DVM forms multiple class .dex byte code file. |
It is based on stack based VM architecture. | It is based on register based VM architecture. |
JVM runs on more memory. | DVM runs on less memory. |
The executable format of JVM is JAR. | The executable format of DVM is APK. |
JVM has different content pools. | DVM has common constant pool. |
It runs .class byte code directly. |
The .class byte codes are optimized to .odex format before executing in DVM. |
3. UI Components and Layouts
2. Explain screen elements for Android.
3. What is directory?
4. Describe directory structure in detail.
5. Explain the term fundamentals of UI design in detail.
- Every item in a User Interfaces (UI) is a subclass of the Android View class whic is present inside the package (android.view).
- The android SDK provides a set of pre-built views that can be used to construct the UI.
6. What is meant by layout?
A layout defines the stucture for User Interface in the application. There are number of Layouts provided by Android which we will use in almost all the Android applicatoins to provide different view, look and feel.
7. Explain Linearlayout with example.
- Android LinearLayout is View group that aligns all children in either vertically or horizontally.
- Vertically or Horizontally direction depends on attribute
android:orientation
LinearLayout is simple and easy to use, it creates a scroll bar if the length of window exceeds the length of the screen. - Attributes of LinearLayout:
id
,orientation
,layout_height
,layout_weight
,gravity
,weight_sum
,divider
. Example:
.xml<?xml version="1.0" encoding="utf-8" ?> <LinearLayout xmlns:android="https://schemas.android.com/apk/res/android" android:layout_height="match_parent" android:layout_width="match_parent" android:orientation="vertical"/> <Button android:id="@id/buttons" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Button" /> </LinearLayout>
8. Describe FrameLayout with example.
9. Explain the following terms:
(i) TableLayout
(ii) AbsoluteLayout
10. Define the term Layout.
A layout defines the stucture for User Interface in the application. There are number of Layouts provided by Android which we will use in almost all the Android applicatoins to provide different view, look and feel.
11. Write down the control flow of an Android application step by step.
13. List the different components of a screen.
14. Explain the term fundamentals of UI design in detail.
15. List various layouts used in Android UI design.
4. Designing User Interface with View
1. What is UI?
- User interface basic building block are View class.
- View is superclass for all the UI components.
- Input controls are interactive components in the app's User Interface(UI).
2. Enlist elements of UI.
- View - View is superclass for all UI compnents.
- TextView - displays text to the user and optionally allows them to edit it.
- EditText - An editable text entry box that accepts multiline entry.
- Button -whcih can be pressed, or clicked, by the user to perform an action.
- ImageButton - shows button with an image that can be pressed or clicked by the user.
- ToggleButton - is used to display checked andunchecked state of a button.
- RadioButton - A radiobutton has two states, either checked or unchecked.
- RadioGroup - RadioButton are maninly used together in RadioGroup.
- CheckBox - is an On/Off switch that can be toggled by the user.
- ProgressBar - is used to show the progress of an operatin.
- ListView - dispalys a vertically-scrollable collection of views, where each view is positioned immediately below the previous viewin the list.
- GridView - shows items in two-dimensional scrolling grid.
- ImageView - shows image with help
android.widget.imageView
class. - ScrollView - is a view group that is used to make vertically scrolllable views.
3. What is TextView? How to create it? Explain with example.
- TextView - displays text to the user and optionally allows them to edit
- A standard read-only text label that supports string formatting, multiline display and automatic word wrapping.
- Attributes of TextView:
- alpha - This property of the view as value between 0 and 1.
- auto-link - controls whether links such as urls and email addresses.
- gravity - attribute is optional attribute which is used to control the alignment of the text left, right, center, top, bottom, center_vertical, center_horizontal etc.
- text - is used to set the text in TextView.
- textColor - is used to set the text color.
- textSize - is used to set the size of text.
- textStyle - is used to set the text style.
- background - is used to set the background.
- padding - is used to set hte padding from left, right, top to bottom.
Example:
.xml<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="https://scemas.android.com/res/apk/android" android:orentation="vertical" android:layout_height="match_parent" android:layout_width="match_parent"> <TextView android:layout_height="wrap_content" android:layout_width="wrap_content" android:text="Hello World" android:gravity="right" android:textColor="#2353" android:textSize="10px" android:background="#000" android:padding="10px"/> </LinearLayout>
4. Explain the term Button with example.
- Button -whcih can be pressed, or clicked, by the user to perform an action.
- There are different types of buttons used in android such as CompoundButton, ToggleButton, RadioButton.
- Button is superclass of TextView class and compound button is the subclass of button class.
- Properties of Button:
- auto-link - controls whether links such as urls and email addresses are automatically found and converted toclickable links.
- clickable - defines whether this viewreacts to click events.
- id - is an attribute used to uniquely identify a text button.
- gravity - is an optional attribute which is used to control the alignement of text like left, right, top, bottom, center_vertical, center_horizontal etc.
- text - is used to set the text in TextView.
- textColor - is used to set the text color.
- textSize - is used to set the size of text.
- textStyle - is used to set the text style.
- background - is used to set the background.
- padding - is used to set hte padding from left, right, top to bottom.
- drawableButton, drawableTop, drawableRight, drawableLeft - we draw drawable to the left, right, top or bottom of text.
5. What is ImageButton? How to create it? Explain with example.
- ImageButton - shows button with an image that can be pressed or clicked by the user.
- Properties of ImageButton:
- id - is an attribute used to uniquely identify a text button.
- src - is used to set a source file of image or we can say image in the image button to make layout look attractive.
- background - is used to set the background.
- padding is used to set padding left, right, top or bottom
Example:
.xml<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="https://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"/> <ImageButton android:id="@+id/imageButton" android:src="@drawable/button" android:layout_height="wrap_content" android:layout_width="wrap_content"/> </LinearLayout>
6. Describe the following UI elements with example.
(i) ListView
- ListView - dispalys a vertically-scrollable collection of views, where each view is positioned immediately below the previous viewin the list.
- Properties of ListView:
- id - is an attribute used to uniquely identify a text button.
- divider - This is a drawable or color draw between different list items.
- dividerHeight - This specify the height of divider between list items.
- listSelector - is used to set the selector of the listView.
Example:
.xml<?xml version="1.0" endcoding="utf-8"?> <LinearLayout xmlns:android="https://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <ListView android:id="@+id/listView" android:layout_width="wrap_content" android:layout_height="wrap_content" android:divider="#000" android:dividerHeight="1dp"/> </LinearLayout>
(ii) ScrollView
ScrollView - is a view group that is used to make vertically scrolllable
It is a
FrameLayout
which put one child in it containg the whole contents to scroll.This is useful when we have too much to fit onto a single screen.
Example:
.xml<?xml version="1.0" encoding="utf-8"?> <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="https://schemas.android.com/apk/res/android" xmlns:app="https://schemas.android.com/apk/res-auto" xmlns:app="https://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:tools=".MainActivity"> <ScrollView android:layout_width="match_parent" android:layout_height="match_parent"> <TextView android:id="@+id/textView" android:layout_height="wrap_content" android:layout_width="wrap_content" android:text="Hello World"/> </ScrollView> </androidx.constraintlayout.widget.ConstraintLayout>
(iii) GridView
- A GridView is type of AdapterView that dispalyas items in two-dimensional scrolling grid.
Example:
.xml<?xml version="1.0" encoding="utf-8"?> <androidx.contraintlayout.widget.ContraintLayout xmlns:android="https://schemas.android.com/apk/res/android" xmlns:tools="https://schemas.android.com/tools" android:tools=".MainActivity" android:layout_width="match_parent" android:layout_width="mathc_parent"> <gridview android:id="@+id/idgv" android:layout_height="wrap_content" android:layout_widht="wrap_content" android:numcoumns="2" android:verticalspacing="6dp"/> </androidx.contraintlayout.widget.contraintlayout>
(iv) imageview.
imageview - shows image with help
android.widget.imageview
class..xml<?xml version="1.0" encoding="utf-8"?> <androidx.contraintlayout.widget.contraintlayout xmlns:android="https://schemas.android.com/apk/res/android" xmlns:app="https://schemas.android.com/apk/res-auto" xmlns:tools="https://schemas.android.com/tools" android:tools=".mainactivity" android:layout_height="match_parent" android:layout_width="match_parent"> <imageview android:id="@+id/imageview" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/image"/> </androidx.contraintlayout.widget.contraintlayout>
7. explain radiogroup with example.
- radiobutton - a radiobutton has two states, either checked or unchecked.
- radiogroup - radiobutton are maninly used together in radiogroup.
- Properties of radiobutton:
- id - is an attribute used to uniquely identify a text button.
- checked - in radio button is used to set the current state of radio button.
- gravity - is an optional attribute which is used to control the alignement of text like left, right, top, bottom, center_vertical, center_horizontal etc.
- text - is used to set the text in TextView.
- textColor - is used to set the text color.
- textSize - is used to set the size of text.
- textStyle - is used to set the text style.
- background - is used to set the background.
- padding - is used to set hte padding from left, right, top to bottom.
- drawableButton, drawableTop, drawableRight, drawableLeft - we draw drawable to the left, right, top or bottom of text.
Example:
.xml<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="https://schemas.android.com/apk/res/android" xmlns:tools="https://schemas.android.com/tools" android:tools=".MainActivity" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <RadioGroup android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/radioGendar"> <RadioButton android:id="@+id/radioMan" android:text="Man" android:layout_height="wrap_content" android:layout_width="wrap_content" android:checked="true"/> <RadioButton android:id="@+id/radioGirl" android:text="Women" android:layout_height="wrap_content" android:layout_width="wrap_content" android:checked="false"/> <RadioGroup> </LinearLayout>
8. With the help of example describe ToggleButton.
- ToggleButton - is used to display checked and unchecked state of a button.
- It is subclass of compound Button.
- Properties of radiobutton:
- id - is an attribute used to uniquely identify a text button.
- checked - in radio button is used to set the current state of radio button.
- gravity - is an optional attribute which is used to control the alignement of text like left, right, top, bottom, center_vertical, center_horizontal etc.
- textOn and textOff - is used to set the text when toggle button is in checked state.
- textColor - is used to set the text color.
- textSize - is used to set the size of text.
- textStyle - is used to set the text style.
- background - is used to set the background.
- padding - is used to set hte padding from left, right, top to bottom.
- drawableButton, drawableTop, drawableRight, drawableLeft - we draw drawable to the left, right, top or bottom of text.
Example:
.xml<?xml version="1.0" encoding="utf-8"?> <androidx.contraintlayout.widget.ContraintLayout xmlns:android="https://schemas.android.com/apk/res/android" xmlns:app="https://schemas.android.com/apk/res-auto" xmlns:tools="https://schemas.android.com/tools" android:tools=".MainActivity" android:layout_width="match_parent" android:layout_height="match_parent"> <ToggleButton android:id="@+id/simpleToggleButton" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_horizontal" android:checked="false" android:textOn="On" android:textOff="Off"/> </android.contraintlayout.wiget.ContraintLayout>
10. How to custom toast alert?
- Toast is used to display information for a period of time.
- It contains a message to be displayed quickly and disappears after specified period of time.
- It does not block the user interaction.
- Tost are not clickable.
Exmaple:
.javaToast.makeText(getApplicationContext(), "Simple Toast in Android", Toast.LENGTH_LONG);
11. Describe Date and Time picker with example.
DatePicker
- DatePicker is a widget used to select a date.
- It allows to select date by date, month and year in our custom UI.
- If we need to show this view as a dialog then wehave to use a DatePickerDialog class.
Example:
.xml<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="https://schemas.android.com/apk/res/android" xmlns:app="https://schemas.android.com/apk/res-auto" xmlns:tools="https://schemas.android.com/tools" android:tools=".MainActivity" android:orentation="vertical" android:layout_height="match_parent" android:layout_width="mathc_parent"/> <DatePicker android:id="@+id/datepicker" android:layout_width="wrap_content" android:layout_height="wrap_content" android:datePickerMode="spinner"/> </LinearLayout>
Method of DatePicker:
setSpinnersShow(boolen show)
- This method is used to set whether the sinner of the TimePicker in shown or not.getDayOfMonth()
- This method is used to get selected day of the month.getMonth()
- This method is used to get the selected month from a date picker.getYear()
- This method is used to get the selected year from a date picker.getFirstDayOfWeek()
- This method is used to get the first day of the week.
Attributes of DatePicker:
- id - is an attribute used to uniquely identify a text button.
- datePickerMode - This attribute is used to set the DatePicker.
TimePicker
- Is a widget used for selecting the time of the day in either AM/PM mode or 24 hours mode.
- The displayed time consist of hours, minutes and clock format.
- Method of TimePicer:
setCurrentHour(integer currentHour)
- This method is used to set the current hours in a TimePicker.setHour(Integer hour)
- This method is used to set the current hours in TimePicker.setCurrentMinute(Integer currentMinute)
- This method is used to set the current minutes in a time.setMinute(Integer minute)
- This method is used to set the current minute in time.setIs24HourView(Boolean is24HourView)
- This method is used to set the mode of Time picker either 24 hours mode or AM/PM mode.is24HourView()
- This method is used to check the current mode of the time picker.setOnTimeChangedListenar()
- This method is used to set the callback that indicates the time has been adjusted by the user.
- Attributes of TimePicker:
timePickerMode
- The time picker mode is attribute of time picker used to set the mode either spinner or clock.
12. What is progress bar? How to create it?
- ProgressBar is used to show the progress of an operation.
- ProgressBar is a visual indicator of progress in a number of operation.
- Attributes of DatePicker:
- id - is an attribute used to uniquely identify a text button.
- max - is an attribute used in android to define maximum value of the progress can take.
- progress - is an attribute used in android to define the default progress value between 0 and Max.
- progressBrawable - is an attribute used to set the custom drawable for the progress mode.
Example:
.xml<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="https://schemas.android.com/apk/res/android" xmlns:tools="https://schemas.android.com/tools" xmlns:app="https://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="mathc_parent"/> <ProgressBar android:id="@+id/progressBar" android:layout_width="wrap_content" android:layout_height="wrap_content" android:max="100" android:progress="0" android:progressDrawable="@drawable/progress"/> </RelativeLayout>
14. Describe the following with example:
(ii) CheckBox.
- Is an On/Off switch that can be toggled by the user.
- A two-state represented by a checked or unchecked box.
Example:
.xml<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="https://schemas.android.com/apk/res/android" xmlns:tools="https://schemas.android.com/tools" xmlns:app="https://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="mathc_parent"/> <CheckBox android:id="@+id/check1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Android" android:checked="true"/> <CheckBox android:id="@+id/check1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="ISO" android:checked="true"/> <CheckBox android:id="@+id/check1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="KaiOS" android:checked="true"/> </RelativeLayout>
15. Draw the hierarchy of designing User Interface (UI) with View.
ββββββ
βViewβββββββββββββββββββββββββ
βββ¬βββ€ β
β ββββββββββ β
β β β
ββ΄ββββββββ βββ΄ββββββββ ββββββ΄βββββ
βTextViewβ βImageViewβ βViewGroupβ
βββββ¬ββ¬βββ ββββββ¬βββββ βββββββββββ
β β β
β ββββββββ ββββββββ
β β β
βββββ΄βββββ βββ΄βββββ ββββ΄βββββββββ
βEditTextβ βButtonβ βImageButtonβ
ββββββββββ ββ¬βββ¬ββ¬β βββββββββββββ
β β β
ββββββββββ β ββββββββββββ
β β β
ββββ΄ββββββ βββββ΄ββββββββ ββββ΄ββββββββββ
βCheckBoxβ βRadioButtonβ βToggleButtonβ
ββββββββββ βββββββββββββ ββββββββββββββ
16. Describe the term "edit text" with example.
- An editable text enty box that accepts multiline entry, word wrapping and hint text.
- A EditText is an overlay over TextView that configures itself to be editable.
Example:
.xml<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="https://schemas.android.com/apk/res/android" xmlns:tools="https://scheams.android.com/tools" xmlns:app="https://scheams.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent" android:tools=".MainActivity"> <EditText android:id="@+id/editIt" android:layout_width="wrap_content" android:layout_height="wrap_content" android:hint="Name:" android:selectAllOnFocus="true" android:inputType="textPersonName"/> </RelativeLayout>
5. Activity & Multimedia with Database
Activity
- An activity represents a single screen with user interface just like window or frame of Java.
- Android activity is the subclass of ContextThemeWrapper class.
- In C, C++ or Java programming language you must have seen that your program
stats from
main()
function. - Android sytem iniiates its program with an Activity starting with a call
onCreate()
callback method.
Draw the activity life cycle.
ββ¬βββββββββ¬β
ββActivityββ
ββlaunchedββ
ββ΄βββββ¬ββββ΄β
β
ββββββΌββββββ
ββββββββββββββββββββββΊonCreate()β
β ββββββ¬ββββββ
β β
β ββββββΌβββββ βββββββββββββ
β βonStart()ββββββββββββββββββββββ€onRestart()β
β ββββββ¬βββββ βββββββββ²ββββ
β β β
User navigates ββββββΌββββββ β
to the activity βonResume()βββββββββββββββββ β
β ββββββ¬ββββββ β β
β β β β
ββ¬ββββββ΄ββββββ¬β ββ¬βββββ΄ββββ¬β β β
ββApp processββ ββActivityββ β β
ββkilled ββ ββRunning ββ β β
ββ΄ββββββ²ββββββ΄β ββ΄βββββ¬ββββ΄β β β
β β β β
β βΌ β β
Apps with higher priority Another activity comes User returns β
need memory into the foreground to the activity β
β β β β
β β β β
β ββββββΌβββββ β β
β βonPause()ββββββββββββββββββ β
β ββββββ¬βββββ β
β β β
β β β
β The activity is β
β no longer visible β
β β User navigates
β β to the activity
β ββββββΌββββ β
ββββββββββββββββββββββ€onStop()βββββββββββββββββββββββββββββββ
ββββββ¬ββββ
β
β
The activity is finishing or
being destroyed by the system
β
β
ββββββΌβββββββ
βonDestroy()β
ββββββ¬βββββββ
β
ββ¬βββββΌβββββ¬β
ββActivity ββ
ββShut Downββ
ββ΄ββββββββββ΄β
Explain activity lifecycle?
- The android Activity is the subclass of ContextThemeWrapper class.
- An activity is the single screen in android. It is like window or frame of Java.
- By the help of activity, you can place all your UI components or widgets in a single screen.
- 7 lifecycle methods of android activity.
- onCreate - called when activity is first created.
- onStart - called when activity is becoming visible to the user.
- onResume - called when activity will start interacting with the user.
- onPause - called when activity is not visible to the user.
- onStop - called when activity is no longer visible to the user.
- onRestart - called after your activity is stopped, prior to start.
- onDestroy - called before the activity is destroyed.
What are intents(Implict
and explicit
intent)?
- Android Intent is the message that is passed between components such as activities, content providers, broadcast receivers, services etc.
- It is generally used with
startActivity()
method to invoke activity, broadcast receivers etc. ο The dictionary meaning of intent is intention or purpose. - So, it can be described as the intention to do action.
- The LabeledIntent is the subclass of android.content.Intent class.
- Android intents are mainly used to:
- Start the service
- Launch an activity
- Display a web page
- Display a list of contacts
- Broadcast a message
- Dial a phone call etc
Implicit intent
The implicit intent is the intent where instead of defining the exact components, you define the action that you want to perform for different activities.
Explicit intent
An explicit intent is an intent where you explicitly define the component that needs to be called by Android System. An explicit intent is one that you use to launch a specific app component, such s a particular activity or service in your app.
Explain content provider?
- Android system allows the content provider to store the application data in
several ways. Users can manage to store the application data like
- Images
- Audio
- Videos
- Personal contact information by storing them in:
- SQLite Database
- Files
- Network.
- In order to share the data, content providers have certain permissions that are used to grant or restrict the rights to other applications to interfere with the data.
List sensors in Android and explain anyone in detail.
The Android platform supports following three broad categories of sensors:
- Motion Sensors
- Environmetal Sensors
- Position sensors
Motion Sensors:
- A motion sensor (or motion detector) is an electronic device that is designed to detect and measure movement.
- Motion sensors are used primarily in home and business security systems.
- These sensors measure acceleration forces and rotational forces along three axes.
- This category includes accelerometers, gravity sensors, gyroscopes, and rotational vector sensors.
Position Sensors
These are used to measure the physical position of device.
Environmental Sensors
These are used to measure the environmental changes such as temperature, humidity etc
Define Services in Android OS.
- A service is an application component which runs withour direst interaction with the user in the background.
- Services are used for repetitive and potentially long running operations:
- Internet downloads
- Checking for new data
- Data processing
- Updating content
- Providers and the like
- They typically run in the background to perform long-running operations or work for remote processes.
CONTENT URI
- Content URI(Uniform Resource Identifier) is the key concept of Content providers.
- To access the data from a content provider, URI is used as a query string.
- Structure of a Content URI:
- content:// β Mandatory part of the URI as it represents that the given URI is a Content URI.
- authority β Signifies the name of the content provider like contacts, browser, etc. This part must be unique for every content provider.
- optionalPath β Specifies the type of data provided by the content provider. It is essential as this part helps content providers to support different types of data that are not related to each other like audio and video files.
- optionalID β It is a numeric value that is used when there is a need to access a particular record.
WORKING OF THE CONTENT PROVIDER
- UI components of android applications like Activity and Fragments use an object CursorLoader to send query requests to ContentResolver.
- The ContentResolver object sends requests (like create, read, update, and delete) to the ContentProvider as a client.
- After receiving a request, ContentProvider process it and returns the desired result.
CREATE CONTENT PROVIDER
This involves number of simple steps to create your own content provider.
- First of all you need to create a Content Provider class that extends the ContentProviderbaseclass.
- Second, you need to define your content provider URI address which will be used to access the content.
- Next you will need to create your own database to keep the content.
- Next you will have to implement Content Provider queries to perform different database specific operations.
Finally register your Content Provider in your activity file using
tag. Methods which you need to override in Content Provider class:
- onCreate() This method is called when the provider is started.
- query() This method receives a request from a client. The result is returned as a Cursor object.
- insert()This method inserts a new record into the content provider.
- delete() This method deletes an existing record from the content provider.
- update() This method updates an existing record from the content provider.
- getType() This method returns the MIME type of the data at the given URI.
FRAGMENT
- A Fragment is a piece of an activity which enable more modular activity design.
- You create fragments by extending Fragment class and You can insert a fragment
into your activity layout by declaring the fragment in the activity's layout
file, as a
element. - A fragment has its own layout and its own behaviour with its own life cycle callbacks.
- You can add or remove fragments in an activity while the activity is running.
- You can combine multiple fragments in a single activity to build a multi-pane UI.
- A fragment can be used in multiple activities.
ANDROID FRAGMENT LIFECYCLE METHODS
Method | Description |
---|---|
onAttach(Activity) | it is called only once when it is attached with activity. |
onCreate(Bundle) | It is used to initialize the fragment. |
onCreateView(LayoutInflater, ViewGroup, Bundle) | creates and returns view hierarchy. |
onActivityCreated(Bundle) | It is invoked after the completion of onCreate() method. |
onViewStateRestored(Bundle) | It provides information to the fragment that all the saved state of fragment view hierarchy has been restored. |
onStart() | makes the fragment visible. |
onResume() | makes the fragment interactive. |
onPause() | is called when fragment is no longer interactive. |
onStop() | is called when fragment is no longer visible. |
onDestroyView() | allows the fragment to clean up resources. |
onDestroy() | allows the fragment to do final clean up of fragment state. |
onDetach() | It is called immediately prior to the fragment no longer being associated with its activity. |
MEDIAPLAYER CLASS
- We can play and control the audio files in android by the help of MediaPlayer class.
- The android.media.MediaPlayer class is used to control the audio or video
files.
| Method & description |
|:------------------------------------------------------------------------------------------------------------------:|
|
isPlaying()
This method just returns true/false indicating the song is playing or not | |seekTo(position)
This method takes an integer, and move song to that particular position millisecond | |getCurrentPosition()
This method returns the current position of song in milliseconds | |getDuration()
This method returns the total time duration of song in milliseconds | |reset()
This method resets the media player | |release()
This method releases any resource attached with MediaPlayer object | |setVolume(float leftVolume, float rightVolume)
This method sets the up down volume for this player | |setDataSource(FileDescriptor fd)
This method sets the data source of audio/video file | |selectTrack(int index)
This method takes an integer, and select the track from the list on that particular index | |getTrackInfo()
This method returns an array of track information |
TEXTTOSPEECH
- Android allows you convert your text into voice. Not only you can convert it but it also allows you to speak text in variety of different languages.
- TextToSpeech class is responsible to convert text into speech.
- It provides a lot of methods to control the speech such as setSpeedRate(),
setPitch() etc.
| Method & description |
|:---------------------------------------------------------------------------------------------------------------:|
|
addSpeech(String text, String filename)
This method adds a mapping between a string of text and a sound file. | |getLanguage()
This method returns a Locale instance describing the language. | |isSpeaking()
This method checks whether the TextToSpeech engine is busy speaking. | |setPitch(float pitch)
This method sets the speech pitch for the TextToSpeech engine. | |setSpeechRate(float speechRate)
This method sets the speech rate. | |shutdown()
This method releases the resources used by the TextToSpeech engine. | |stop()
This method stop the speak. |
Android AsyncTask example and explanation
- Android AsyncTask going to do background operation on background thread and update on main thread.
- In android we cant directly touch background thread to main thread in android development. asynctask help us to make communication between background thread to main thread.
Methods of AsyncTask
onPreExecute()
β Before doing background operation we should show something on screen like progressbar or any animation to user. we can directly comminicate background operation using ondoInBackground()
- but for the best practice, we should call all asyncTask methods .doInBackground(Params)
β In this method we have to do background operation on background thread. Operations in this method should not touch on any mainthread activities or fragments.onProgressUpdate(Progressβ¦)
β While doing background operation, if you want to update some information on UI, we can use this method.onPostExecute(Result)
β In this method we can update ui of background operation result.
Generic Types in Async Task
TypeOfVarArgParams
β It contains information about what type of params used for execution.ProgressValue
β It contains information about progress units. While doing background operation we can update information on ui using onProgressUpdate().ResultValue
βIt contains information about result type.
LOCATION BASED SERVICES
- Android location APIs make it easy for you to build location-aware applications, without needing to focus on the details of the underlying location technology.
- This becomes possible with the help of Google Play services, which facilitates adding location awareness to your app with automated location tracking, geofencing, and activity recognition.
- For this Google provides us a library via Google Play Services for using maps.
- In order to use the Google Maps API, you must register your application on the Google Developer Console and enable the API.
SMS TELEPHONY
- In Android, you can use SmsManager API or devices Built-in SMS application to send SMS's.
SmsManager API
.javaSmsManager smsManager = SmsManager.getDefault(); sms.sendTextMessage("8802177690", null, "hello javatpoint", pi,null);
Built-in SMS application
.javaIntent sendIntent = new Intent(Intent.ACTION_VIEW); sendIntent.putExtra("sms_body", "default content"); sendIntent.setType("vnd.android-dir/mms-sms"); startActivity(sendIntent);
Both need SEND_SMS permission.
.xml<uses-permission android:name="android.permission.SEND_SMS" />
1. Write a program to place Name, Age, Mobile number linearly(vertical) on the display screen using Linear layout.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:paddingTop="16dp"
android:orientation="vertical"
tools:context=".MainActivity">
<TextView
android:id="@+id/student_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Name:" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Age:" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Mobile Number:" />
</LinearLayout>
2. Write a program to place Name, Age, Mobile number linearly(vertical) on the display screen using Absolute layout.
<?xml version="1.0" encoding="utf-8"?>
<AbsoluteLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="16dp"
android:paddingTop="16dp"
android:paddingRight="16dp"
tools:context=".MainActivity">
<TextView
android:id="@+id/student_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="125dp"
android:layout_y="280dp"
android:text="Name:"
android:textColor="#86AD33"
android:textSize="20dp"
android:textStyle="bold" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="125dp"
android:layout_y="304dp"
android:text="Age:"
android:textColor="#86AD33"
android:textSize="20dp"
android:textStyle="bold" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="125dp"
android:layout_y="328dp"
android:text="Mobile Number:"
android:textColor="#86AD33"
android:textSize="20dp"
android:textStyle="bold" />
</AbsoluteLayout>
3. Write a program to display 5 students basic information in a table form using Table layout.
<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:collapseColumns="*"
android:shrinkColumns="*"
tools:context=".MainActivity">
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="10 Students Basic Information"
android:textColor="#86AD33"
android:textSize="20dp"
android:textStyle="bold" />
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="0dp"
android:layout_weight="1"
android:text="Student Numbers"
android:textColor="#000"
android:textStyle="bold" />
<TextView
android:layout_width="0dp"
android:layout_weight="1"
android:text="Name"
android:textColor="#000"
android:textStyle="bold" />
<TextView
android:layout_width="0dp"
android:layout_weight="1"
android:text="RollNo"
android:textColor="#000"
android:textStyle="bold" />
<TextView
android:layout_width="0dp"
android:layout_weight="1"
android:text="Age"
android:textColor="#000"
android:textStyle="bold" />
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:text="Student 1:"
android:textColor="#86AD33"
android:textStyle="bold" />
<EditText
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
/>
<EditText
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content" />
<EditText
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content" />
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="0dp"
android:layout_weight="1"
android:text="Student 2:"
android:textColor="#86AD33"
android:textStyle="bold" />
<EditText
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content" />
<EditText
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content" />
<EditText
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content" />
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="0dp"
android:layout_weight="1"
android:text="Student 3:"
android:textColor="#86AD33"
android:textStyle="bold" />
<EditText
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content" />
<EditText
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content" />
<EditText
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content" />
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="0dp"
android:layout_weight="1"
android:text="Student 4:"
android:textColor="#86AD33"
android:textStyle="bold" />
<EditText
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content" />
<EditText
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content" />
<EditText
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content" />
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="0dp"
android:layout_weight="1"
android:text="Student 5:"
android:textColor="#86AD33"
android:textStyle="bold" />
<EditText
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content" />
<EditText
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content" />
<EditText
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content" />
</TableRow>
</TableLayout>
4. Write a program to accept username and password from the end user using Text View and edit Text.
<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="50dp"
tools:context=".MainActivity">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:textSize="25dp"
android:text="Login Page" />
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal">
<TextView
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="Enter UserName:" />
<EditText
android:id="@+id/user"
android:layout_height="wrap_content"
android:layout_weight="1"
android:hint="abc@gmail.com" />
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal">
<TextView
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="Enter Password:" />
<EditText
android:id="@+id/pass"
android:layout_height="wrap_content"
android:layout_weight="1"
android:hint="1234" />
</TableRow>
<Button
android:id="@+id/btn1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="172dp"
android:text="Login" />
</TableLayout>
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
public class MainActivity extends AppCompatActivity {
EditText user,pass;
Button b;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
b= findViewById(R.id.btn1);
user = findViewById(R.id.user);
pass = findViewById(R.id.pass);
b.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if(user.getText().toString().equals("atharva") & pass.getText().toString().equals("1234"))
?
{
Toast.makeText( getApplicationContext(),"Login Sucessful",Toast.LENGTH_SHORT).show();
}
else
{
Toast.makeText( getApplicationContext(),"Login UnSucessful",Toast.LENGTH_SHORT).show();
}
}
});
}
}
5. Write a program to create a toggle button to display ON/OFF Bluetooth on the display screen.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity"
android:padding="20dp">
<ToggleButton
android:id="@+id/toggleButton"
android:layout_width="wrap_content"
android:layout_height="50dp"
android:text="ToggleButton"
android:textOn="ON"
android:textOff="OFF"
android:textSize="20sp"
android:layout_centerInParent="true"/>
<TextView android:id="@+id/textView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/toggleButton"
android:text="Bluetooth is OFF"
android:gravity="center_horizontal"
android:layout_marginTop="20dp"
android:textSize="20sp"
android:textColor="@color/colorAccent"/>
</RelativeLayout>
package com.example.togglebuttonbluetooth;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.CompoundButton;
import android.widget.TextView;
import android.widget.ToggleButton;
public class MainActivity extends AppCompatActivity {
ToggleButton toggleButton;
TextView textView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
toggleButton = findViewById(R.id.toggleButton);
textView = findViewById(R.id.textView);
toggleButton.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if(isChecked)
{
textView.setText("Bluetooth is " + toggleButton.getTextOn());
}
else
{
textView.setText("Bluetooth is " + toggleButton.getTextOff());
}
}
});
}
}
6. Write a program to create a login form for a social networking site.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#495B8F"
android:padding="20dp"
tools:context=".MainActivity">
<TextView android:id="@+id/logo"
android:layout_width="match_parent"
android:layout_height="80dp"
android:text="F A C E B O O K"
android:gravity="center"
android:textSize="40sp"
android:textStyle="bold"
android:layout_marginTop="40dp"
android:textColor="@android:color/white"/>
<EditText
android:id="@+id/username"
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_below="@id/logo"
android:layout_marginTop="30dp"
android:background="@android:color/white"
android:fontFamily="monospace"
android:hint="Email or phone number"
android:padding="10dp"
android:textSize="22sp" />
<EditText
android:id="@+id/password"
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_below="@id/username"
android:background="@android:color/white"
android:fontFamily="monospace"
android:hint="Password"
android:padding="10dp"
android:layout_marginTop="20dp"
android:textSize="22sp" />
<Button android:id="@+id/btnLogin"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_below="@id/password"
android:layout_marginTop="30dp"
android:text="Log In"
android:background="#6D9ADD"
android:textColor="@android:color/white"
android:textSize="18sp"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:text="Forgot Password?"
android:textColor="@android:color/white"
android:layout_below="@id/btnLogin"
android:layout_marginTop="10dp"
android:textSize="16sp"/>
</RelativeLayout>
package com.example.socialnetworkingapp;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}
7. Write a program to show five checkboxes and toast selected checkbox.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="10dp"
tools:context=".MainActivity">
<CheckBox
android:id="@+id/cb1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Android"
android:textSize="25dp"
android:layout_gravity="center"
android:padding="10dp"
android:checked="false"/>
<CheckBox
android:id="@+id/cb2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Pythpn"
android:textSize="25dp"
android:layout_gravity="center"
android:padding="10dp"
android:checked="false"/>
<CheckBox
android:id="@+id/cb3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="PHP"
android:textSize="25dp"
android:layout_gravity="center"
android:padding="10dp"
android:checked="false"/>
<CheckBox
android:id="@+id/cb4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="C"
android:textSize="25dp"
android:layout_gravity="center"
android:padding="10dp"
android:checked="false"/>
<CheckBox
android:id="@+id/cb5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Java"
android:textSize="25dp"
android:layout_gravity="center"
android:padding="10dp"
android:checked="false"/>
<Button
android:id="@+id/btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Submit"
android:textSize="35dp"
android:layout_gravity="center"
android:padding="10dp"/>
</LinearLayout>
8. Write a program to display circular progress bar.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_horizontal"
android:orientation="vertical"
tools:context=".MainActivity">
<RelativeLayout
android:id="@+id/progress_layout"
android:layout_width="200dp"
android:layout_height="200dp"
android:layout_margin="100dp">
<!--progress bar implementation-->
<ProgressBar
android:id="@+id/progress_bar"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/circular_shape"
android:indeterminate="false"
android:progressDrawable="@drawable/circular_progress_bar"
android:textAlignment="center" />
<!--Text implementation in center of the progress bar-->
<TextView
android:id="@+id/progress_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:gravity="center"
android:text="---"
android:textColor="@color/colorPrimary"
android:textSize="28sp"
android:textStyle="bold" />
</RelativeLayout>
</LinearLayout>
import android.os.Bundle;
import android.os.Handler;
import android.widget.ProgressBar;
import android.widget.TextView;
import androidx.appcompat.app.AppCompatActivity;
public class MainActivity extends AppCompatActivity {
private ProgressBar progressBar;
private TextView progressText;
int i = 0;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// set the id for the progressbar and progress text
progressBar = findViewById(R.id.progress_bar);
progressText = findViewById(R.id.progress_text);
final Handler handler = new Handler();
handler.postDelayed(new Runnable() {
@Override
public void run() {
// set the limitations for the numeric
// text under the progress bar
if (i <= 100) {
progressText.setText("" + i);
progressBar.setProgress(i);
i++;
handler.postDelayed(this, 200);
} else {
handler.removeCallbacks(this);
}
}
}, 200);
}
}
9. Write a program to display 15 buttons using Grid view.
10. Write a program to display a toast message
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;
public class MainActivity extends AppCompatActivity {
Button b1;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
b1 = (Button) findViewById(R.id.toast_button);
b1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(MainActivity.this,"You just Toasted me!!!",Toast.LENGTH_LONG).show();
/*Another way to display a Toast message
Toast t=Toast.makeText(MainActivity.this,"You just Toasted me!!!",Toast.LENGTH_LONG);
t.show();
*/
}
});
}
}
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="codedost.toast.MainActivity">
<Button
android:id="@+id/toast_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Toast me!"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true"
/>
</RelativeLayout>
MAD QUESTION BANK
1. Write the syntax for Intent-Filter tag.
<intent-fliter
android:icon="drawable resource"
android:label="string resource"
android:priority="integer">
</intent-fliter>
2. Define Services in Android OS.
- A service is an application component which runs withour direst interaction with the user in the background.
- Services are used for repetitive and potentially long running operations:
- Internet downloads
- Checking for new data
- Data processing
- Updating content
- Providers and the like
- They typically run in the background to perform long-running operations or work for remote processes.
1. Started
- The service start with startService() function.
- To stop the service we can use stopService() & stopSelf() function.
2. Bound
- A service is bound when an application component binds to it by calling bindService().
- To un bound the service we can use unbindService() function.
3. Enlist the steps to publish the Android application
- Step 1 - Sign up or Sign in for an account on the Android Developer console.
- Step 2 - Create a new appplication.
- Step 3 - Prepare multimedia.
- Step 4 - Prepare code for release.
- Step 5 - Build a release-ready APK.
- Step 6 - Upload APK complete the checklist on the left until all the items have a green checkmark.
5. What is Date and Time picker with its methods?
Date Picker
- Android Date Picker allows you to select the date consisting of day, month and year in your custom user interface.
- Methods of DatePicker:
- getDayOfMonth() - This method gets the selected day of month.
- getMonth() - This method gets the selected month.
- getYear() - This method gets the selected year.
- getFirstDayOfWeek() - This method returns first day of the week.
- getCalendarView() - This method returns calender View.
TimePicker
- Android Time Picker allows us to select the time of day in either 24h or AM/PM mode.
- The time consists of hours, minutes and clock format.
- Methods of TimePicker
- setCurrentHour() - This method sets the current hour.
- setCurrentMinute() - This method sets the current minute.
- is24HoursView() - This method returns true if this 24 hour view else false.
- isEnabled() - This method returns the enabled status for this view.
6. Write a program to display circular progress bar.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="https://schemas.android.com/apk/res/android"
xmlns:app="https://schemas.android.com/apk/res-auto"
xmlns:tools="https://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<Button
android:id="@+id/btnDownloadFile"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Download File"
andorid:layout_centerInParent="true" />
</RelativeLayout>
7. List sensors in Android and explain anyone in detail.
The Android supports broad categories of sensors:
- Motion Sensors
- Enviromental Sensors
- Position Sensors
Montion Sensors:
- A motion sensor (or motion detector) is an electronic device that is designed to detect and measure movements.
- Motion sensors are used primarily in home and business secrity systems.
- These sensors measure accelecation forces and rotational forces along three axes.
8. Develop the registration form using the following GUI.
<RelativeLayout
xmlns:android="https://schemas.android.com/apk/res/android"
xmlns:tools="https://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="wrap_content"
android:paddingTop="wrap_content"
tools:context=".MainActivity">
<FrameLayout>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/banner_image" />
<FrameLayout>
<EditText
android:id="@+id/editText1"
android:hint="Name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:drawableLeft="@drawable/name_image" />
<EditText
android:id="@+id/editText2"
android:hint="Email ID"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:drawbleLeft="@drawable/email_image" />
<EditText
android:id="@+id/editText1"
android:hint="Password"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:drawableLeft="@drawable/pass_image" />
<EditText
android:id="@+id/editText1"
android:hint="Confirm Password"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_cneterVertical="true"
android:drawableLeft="@drawable/conpass_image" />
<EditText
android:id="@+id/editText1"
android:hint="Enter Mobile"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:drawableLeft="@drawable/mobile_image" />
<RadioButton
android:id="@+id/radioMale"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Male" />
<RadioButton
android:id="@+id/radioFemale"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Female" />
<Button
android:id="@+id/btnDisplay"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Register" />
</RelativeLayout>
(thk to SaturoGojoo,AK,NEWBIEN00B)
1) What is android?
Android is a mobile operating system based on a modified version of the Linux kernel and other open source software, designed primarily for touchscreen mobile devices such as smartphones and tablets.
2) Enlist Features of android?
- Open Source
- Beautiul UI
- Connectivity
- Storage
- Multi-Touch
- Multi-Tasking
- Multi-Language
- Resizable widgets
- Messaging
- Media Support
- Web Browser
3) Explain android architecture?
Android architecture contains different number of components to support any android device needs. Android software contains an open-source Linux Kernel having collection of number of C/C++ libraries which are exposed through an application framework services.
The main components of android architecture are following:
Applications: Applications is the top layer of android architecture. The pre-installed applications like home, contacts, camera, etc and third party applications will be installed on this layer only.
Application framework: Application Framework provides several important classes which are used to create an Android application.
Application runtime: Android Runtime environment contains components like core libraries and the Dalvik virtual machine(DVM).
Platform libraries: The Platform Libraries includes various C/C++ core libraries and Java based libraries such as Media, Graphics, OpenGL etc. to provide a support for android development.
Linux Kernel: The linux kernel manages all the available drivers such as display drivers, camera drivers, audio drivers, etc. which are required during the runtime.
4) Explain android sdk?
- The Android software development kit(SDK) allows developers to create applications for the Android platform. The Android SDK is the most important software of Android which is installed.
- The Android SDK provides to test application API libraries and emulator documentation sample code developer tools and tutorials which helps us to build and test the debug apps from Android.
- Android SDK provides the tools and application programming interface(API) for developers to create applications on the Android platform using Java programming language.
5) What is Android AVD?
- An AVD is an emulator configuration that enables to modules an actual device by calling hardware and software option to be emulated by the Android emulator.
- The AVD manager is an interface that we can launch from android studio which helps us to create and manage AVD.
- An AVD contains hardware profile, system image, storage area, skin and other properties.
- AVD contains emulator for Wear OS, TV, Mobile Phones, Tables, Automotive.
Hardware profile
- Hardware profile defines the characteristics of a device as shipped from the factory of a device as shipped from the factory.
- The AVD manager comes preloaded with certain hardware profile such as Pixel device and we can define or customize the hardware profile as needed.
System image
- A system image labelled with Google API includes access to Google Play services.
- A system image Labelled with Google Play logo in the Play Store includes the Google Play Store apps and can access to the Google Play Services.
Storage Area
- The AVD has dedicated storage area on our development machine.
- It stores the devices data such as installed apps and settings, as well as emulated and SD cards.
- If needed we can use the AVD manager to wipe user data so that the devices has the same data as if it was a new device.
6) What is emulator?
The Android Emulator simulates Android devices on your computer so that you can test your application on a variety of devices and Android API levels without needing to have each physical device.
7) Difference between JVM and dVM?
JVM | DVM |
---|---|
JVM supports multiple OS | DVM supports only Android Operating system. |
JVM forms separate classes in separate .class byte code files. |
DVM forms multiple class in .dex byte code file. |
It is based on stack based virtual machine architecture. | It is based on register based virtual machine architecture. |
JVM runs on more memory | DVM runs on less memory. |
The executable format of JVM is JAR. | The executable format of DVM is APK. |
JVM has different constant pools. | DVM has common constant pool. |
It runs .class byte code directly. |
The .class byte codes are optimize to .odex format before executing in DVM. |
8) What are activities?
- Activities dictate the UI and handles the user interaction to the smart phone screen.
- Activities represent a single screen that user interact.
9) What are services?
- A service is an application component which runs in the background.
- There are three types of service in Android:
Foreground service
- A foreground service performs some operation that is noticeable to the user.
- For example, an audio app would use a foreground service to play an audio track.
- Foreground services must display a Notification. Foreground services continue running even when the user isn't interacting with the app.
Backgroud Service**
- A background service performs an operation that isn't directly noticed by the user.
- For example, if an app used a service to compact its storage, that would usually be a background service.
Bound Service
- A service is bound when an application component binds to it by calling bindService().
- A bound service offers a client-server interface that allows components to interact with the service, send requests, receive results, and even do so across processes with interprocess communication (IPC).
10) What are intents(Implict
and explicit
intent)?
Implicit intent
The implicit intent is the intent where instead of defining the exact components, you define the action that you want to perform for different activities.
Explicit intent
An explicit intent is an intent where you explicitly define the component that needs to be called by Android System. An explicit intent is one that you use to launch a specific app component, such s a particular activity or service in your app.
11) Explain main Activity file ,manifest and layout file?
MainActivity file The main activity. Java file is automatically kept in this folder by Android studio all the classes will be available here and Android studio will even bundle together the package so that we can work with the file without having to go through all the folders.
Manifest file It contains an Android manifest.xml file that is generated by Android studio when we create a project. This file contains the configuration parameters of a project such as Permission services and additional libraries.
Layout file Layout specifies the various widgets to be used in the UI and the relationships between such widgets and their containers. Layout files are stored in "res-> layout" in the Android application.
12) What are different types of UI compents?
TextView TextView is a UI Component that displays the text to the user on their Display Screen. EditText EditText is a user interface control that allows the users to enter some text. Button This is a UI that is used to perform some action as soon as the user clicks on it. ProgressBar Progress bars are used to show progress of a task. For example, when you are uploading or downloading something from the internet, it is better to show the progress of download/upload to the user. In android there is a class called Progress Dialog that allows you to create progress bar.
13) What are Layouts (LinearLayout
, AbsoluteLayout
, TableLayout
, FrameLayout
, RelativeLayout
)?
LinearLayout is a view group that aligns all children in a single direction, vertically or horizontally. AbsoluteLayout enables us to specify the exact location of its children. TableLayout is a view that groups views into rows and columns. RelativeLayout is a view group that displays child views in relative positions. FrameLayout is a placeholder on screen that we can use to display a single view.
14) Define: textview
, Edittextview
, Button
, Image button
, checkbox
(attributes and methods)?
- TextView - This control is used to display text to the user.
- EditTextView - EditText is a predefined subclass of TextView that includes rich editing capabilities.
- Button - A push-button that can be pressed, or clicked, by the user to perform an action.
- ImageButton - An ImageButton is an AbsoluteLayout which enables you to specify the exact location of its children. This shows a button with an image (instead of text) that can be pressed or clicked by the user.
- CheckBox - An on/off switch that can be toggled by the user. You should use check box when presenting users with a group of selectable options that are not mutually exclusive.
15) Explain listview
, gridview
, imageview
, scrollview
?
- ListView - List of scrollable items can be displayed in Android using ListView. It helps you to displaying the data in the form of a scrollable list.
- GridView - It is a view group that display items in two dimensional scrolling grid (rows and columns), the grid items are not necessarily predetermined but they are automatically inserted to the layout using a ListAdapter.
- ImageView - It is used to display an image file in application.
- Scrollview - It is a view group that is used to make vertically scrollable views. A scroll view contains a single direct child only.
16) What is toast explain with example?
- Toast is used to display information for a period of time.
- It contains a message to be displayed quickly and disappears after specified period of time.
- It does not block the user interaction.
Example:
.xml=Toast.makeText(getApplicationContext(),"Hello Javatpoint",Toast.LENGTH_SHORT).show();
17) Explain activity lifecycle?
<!-- Android Activity Lifecycle is controlled by 7 methods of android.app.Activity class.
The android Activity is the subclass of ContextThemeWrapper class.
An activity is the single screen in android. It is like window or frame of Java.
By the help of activity, you can place all your UI components or widgets in a single screen.
-->
- 7 lifecycle methods of android activity.
- onCreate - called when activity is first created.
- onStart - called when activity is becoming visible to the user.
- onResume - called when activity will start interacting with the user.
- onPause - called when activity is not visible to the user.
- onStop - called when activity is no longer visible to the user.
- onRestart - called after your activity is stopped, prior to start.
- onDestroy - called before the activity is destroyed.
18) Explain broadcast receivers?
Broadcast Receivers simply respond to broadcast messages from other applications or from the system itself. These messages are sometime called events or intents.
Creating the Broadcast Receiver
A broadcast receiver is implemented as a subclass of Broadcast Receiver class and overriding the onReceive()
method where each message is received as an Intent object parameter.
Registering Broadcast Receiver
An application listens for specific broadcast intents by registering a broadcast receiver in AndroidManifest.xml file. Consider we are going to register MyReceiver for system generated event ACTION_BOOT_COMPLETED
which is fired by the system once the Android system has completed the boot process.
19) Explain content provider?
Android system allows the content provider to store the application data in several ways. Users can manage to store the application data like images, audio, videos, and personal contact information by storing them in SQLite Database, in files, or even on a network. In order to share the data, content providers have certain permissions that are used to grant or restrict the rights to other applications to interfere with the data.
20) What is sensors?
- Most Android-powered devices have built-in sensors that measure motion, orientation, and various environmental conditions.
- These sensors are capable of providing raw data with high precision and accuracy, and are useful if you want to monitor three-dimensional device movement or positioning, or you want to monitor changes in the ambient environment near a device.
- There are three type of sensors in android:
Mostion sensors
These sensors measure acceleration forces and rotational forces along three axes. This category includes accelerometers, gravity sensors, gyroscopes, and rotational vector sensors.
Environmental sensors
These sensors measure various environmental parameters, such as ambient air temperature and pressure, illumination, and humidity. This category includes barometers, photometers, and thermometers.
Position sensors
These sensors measure the physical position of a device. This category includes orientation sensors and magnetometers.
21) What is location based services?
Location Based Services: Creating the Project, Getting the Maps API Key, Displaying the Map, Displaying the Zoom Control, Navigating to a Specific Location, Adding Markers, Getting Location,Geocoding and Reverse Geocoding, Getting Location Data, Monitoring Location.
22) What is Geo code and reverse Geo code?
Geo code
Geocoding is the process of converting addresses (like a street address) into geographic coordinates (like latitude and longitude), which you can use to place markers on a map, or position the map.
Reverse Geo code
Reverse geocoding is the process of converting geographic coordinates into a human-readable address.
23) Enlist Steps to publish android application?
Step 1: First generate signed apk of your Android App to publish it on Play Store. Step 2: Sign up for Google Play Console to publish and manage your Android App. Step 3: Now click on Create Application. Step 4: Now fill store listing details of your App which include Title, Short and Full description. Step 5: Now Click on ready on publish along with save draft and click on Manage release. Step 6: After Manage production click on edit release. Step 7: Now click on review. Step 8: After review click on Start Rollout to production.
24) What is Date and time Picker?
Datepicker
- Datepicker is a widget used to select a date. It allows to select date by day, month and year in your custom UI (user interface).
- Methods of DatePicker inckudes getDayOfMonth(), getMonth(), getYear(), getFirstDayOfWeek()
Timepicker
- Timepicker is a widget used for selecting the time of the day in either AM/PM mode or 24 hours mode. The displayed time consist of hours, minutes and clock format.
- Methods of Timepicker inckudes setCurrentHour(), setHour(), setCurrentMinute(), getCurrentMinute()
1) What is Android?
Android is mobile OS based on modified version of Linux kernel and other open source software, designed primarily for touchscreen mobile devices such as smartphones and tablets.
2) Enlist features of Android?
- Open Source - Android is open-source, which helps to develop customized android version for future updates.
- Customizable - Anyone can customize the Android Platform.
- Connectivity - It provides GSM, CDMA, Bluetooth, WiFi etc.
- Storage - Many android devices support external storage through Micro SD card.
- Widgets, Multi-Tasking, Multi-Touch, Media Support
3) Explain Android architecture?
- Android architecture contains different number of components to support any android device needs.
- The main components of Android architecture are following:
- Applications - Applications is the top layer of android architecture. The pre-installed applications like will be installed on this layer only.
- Application framework - Application framework provides several important classes which are used to create an Android application.
- Platform libraries - The platform libraries includes versions C/C++ core libraries such as Media, Graphics, OpenGL etc. To provide a support for android development.
- Linux Kernel - The Linux Kernel manages all the available drivers such as display drivers, camera drivers, audio drivers, etc. Which are required during the runtime.
4) Explain Android SDK?
- The Android software development kit(SDK) allows developers to create applications for the Android platform. The Android SDK is the most important software of Android which is installed.
- The Android SDK provides to test application API libraries and emulator documentation sample code developer tools and tutorials which helps us to build and test the debug apps from Android.
- Android SDK provides the tools and application programming interface(API) for developers to create applications on the Android platform using Java programming language.
5) What is Android AVD?
- An AVD is an emulator configuration that enables to modules an actual device by calling hardware and software option to be emulated by the Android emulator.
- The AVD manager is an interface that we can launch from android studio which helps us to create and manage AVD.
- An AVD contains hardware profile, system image, storage area, skin and other properties.
- AVD contains emulator for Wear OS, TV, Mobile Phones, Tables, Automotive.
Hardware profile
- Hardware profile defines the characteristics of a device as shipped from the factory of a device as shipped from the factory.
- The AVD manager comes preloaded with certain hardware profile such as Pixel device and we can define or customize the hardware profile as needed.
System image
- A system image labelled with Google API includes access to Google Play services.
- A system image Labelled with Google Play logo in the Play Store includes the Google Play Store apps and can access to the Google Play Services.
Storage Area
- The AVD has dedicated storage area on our development machine.
- It stores the devices data such as installed apps and settings, as well as emulated and SD cards.
- If needed we can use the AVD manager to wipe user data so that the devices has the same data as if it was a new device.
6) What is emulator?
The Android Emulator simulates Android devices on your computer so that you can test your application on a variety of devices and Android API levels without needing to have each physical device.
7) Difference between JVM and DVM?
JVM | DVM |
---|---|
JVM supports multiple OS | DVM supports only Android OS |
JVM forms separate classes in separate .class byte code files. |
DVM forms multiple class in .dex byte code file. |
JVM runs on more memory | DVM runs on less memory. |
The executable format of JVM is JAR | The executable format of DVM is APK. |
JVM has different constant pools. | DVM has common constant pool. |
It runs .class byte code directly.. |
The .class byte codes are optimize to .odex format before executing in DVM. |
JVM has different constant pools. | DVM has common constant pool. |
8) What are activities?
- Activates dictate the UI and handles the user interaction to the smartphone screen.
- Activates represent a single screen that user interact.
9) What are services?
- There are Three types of services in Android:
- Foreground service
- Background service
- Bound service
Foreground service
- A foreground service performs some operation that noticeable to the user.
- Foreground services must display a Notification.
- Foreground service continue running even when the user isn't interacting with the app.
- Example: An audio app would use a foreground service to play an audio track.
Background Service
- A background service performs an operating that isn't directly noticed by user.
- Example: If an app used a service to compact its storage, that would usually be a background service.
Bound Service
- A service is bound when an application component binds to it by calling
bindService()
. - A bound service offers a client-server interface that allows components to interact with the service, send requests, receive results, and even do so across processes with Interprocess Communication(IPC).
10) What are intents?
Implicit intent
The implicit intent is the intent where instead of defining the exact components , you define the action that you want to perform for different activities.
Explicit intent
An explicit intent is an intent where you explicitly define the component that needs to be called by Android System. An explicit intent is one that you use to launch a specific app component, such as particular activity or service in your app.
11) Explain MainActivity, Manifest & Layout file?
MainActivity
The MainActivity.java file is automatically kept in main folder by Android Studio all the classes will be available here and Android Studio will even bundle together the package so that we can work with the file without having to go through all the folders.
Manifest
Manifest file generated by Android Studio when we create a project. This file contains the configuration parameters of a project such as permission services and additional libraries.
Layout
Layout specifies the various widgets to be used in UI and the relationships
between such widgets and their containers. Layout files are stored in
res->layout
in the Android application.
12) What are different types of UI components?
TextView
- is a UI component that displays the text to the user on the user display screen.EditText
- is a UI control that allows the user to enter some text.Button
- is a UI that is used to perform some action as soon as the user clicks on it.ProgressBar
- are used to show progress of a task.
13) What are Layouts?
LinearLayout
- is a view group that aligns all children in a single direction, vertically or horizontally.AbsoluteLayout
- enables us to specify the exact location of its children.TableLayout
- is a view that groups views into rows and columns.RelativeLayout
- is a view group that displays child views in relative positions.FrameLayout
- is a placeholder on screen that we can use to display a single view.
14) Define
TextView
- This control is used to display text to the user.EditTextView
- EditText is a predefined subclass of TextView that includes rich editing capabilities.Button
- A push-button that can be pressed, or clicked, by the user to perform an action.ImageButton
- An ImageButton is an AbsoluteLayout which enables you to specify the exact location of its children. This shows a button with an image (instead of text) that can be pressed or clicked by the user.CheckBox
- An on/off switch that can be toggled by the user. You should use check box when presenting users with a group of selectable options that are not mutually exclusive.
15) Explain
ListView
- List of scrollable items can be displayed in Android using ListView. It helps you to displaying the data in the form of a scrollable list.GridView
- It is a view group that display items in two dimensional scrolling grid (rows and columns), the grid items are not necessarily predetermined but they are automatically inserted to the layout using a ListAdapter.ImageView
- It is used to display an image file in application.Scrollview
- It is a view group that is used to make vertically scrollable views. A scroll view contains a single direct child only.
16) What is toast explain with example?
- Toast is used to display information for a period of time.
- It contains a message to be displayed quickly and disappears after specified period of time.
- It does not block the user interaction.
Example:
.xmlToast.makeText(getApplicationContext(),"Hello Javatpoint",Toast.LENGTH_SHORT).show();
17) Explain activity life cycle?
onCreate
- called when activity is first created.onStart
- called when activity is becoming visible to the user.onResume
- called when activity will start interacting with the user.onPause
- called when activity is not visible to the user.onStop
- called when activity is no longer visible to the user.onRestart
- called after your activity is stopped, prior to start.onDestroy
- called before the activity is destroyed.
18) Explain broadcast receivers?
Broadcast Receivers simply respond to broadcast messages from other applications or from the system itself. These messages are sometime called events or intents.
Creating the Broadcast Receiver
A broadcast receiver is implemented as a subclass of Broadcast Receiver class
and overriding the onReceive()
method where each message is received as an
Intent object parameter.
Registering Broadcast Receiver
An application listens for specific broadcast intents by registering a broadcast
receiver in AndroidManifest.xml file. Consider we are going to register
My Receiver for system generated event ACTION_BOOT_COMPLETED
which is fired
by the system once the Android system has completed the boot process.
19) Explain content provider?
- Android system allows the content provider to store the application data in several ways.
- Users can manage to store the application data like images, audio, videos, and personal contact information by storing them in SQLite database, in files or even on a network.
- In order to share the data, content providers have certain permissions that are used to grant or restrict the right to other applications to interfere with the data.
20) What is sensors?
- Most Android powered devices have built-in sensors that measure motion, orientation, and various environmental conditions.
- There are three type of sensors in Android:
- Motion
- Environmental
- Position
Motion
These sensors measure acceleration forces and rotational forces along three axes . This category includes accelerometers, gravity sensors, gyroscopes, and rotational vector.
Environmental
These sensors measure various environmental parameters, such as ambient air temperature and pressure, illumination, and humidity. This category includes barometers, photometers, and thermometers.
Position
These sensors measure the physical position of a device. This category includes orientation sensors and magnetometers.
21) What is location based services?
Location Based Services: Location-Based Services(LBS) are present in Android to provide you with features like current location detection, display of nearby places, Geofencing, etc. It fetches the location using your deviceβs GPS, WiFi, or Cellular Networks.
22) What is Geo code and Reverse geo code?
Geo code
Geocoding is the process of converting addresses (like a street address) into geographic coordinates (like latitude and longitude), which you can use to place markers on a map, or position the map.
Reverse Geo code
Reverse geocoding is the process of converting geographic coordinates into a human-readable address.
23) Enlist Steps to publish android application?
- Step 1: First generate signed apk of your Android App to publish it on Play Store.
- Step 2: Sign up for Google Play Console to publish and manage your Android App.
- Step 3: Now click on Create Application.
- Step 4: Now fill store listing details of your App which include Title, Short and Full description.
- Step 5: Now Click on ready on publish along with save draft and click on Manage release.
- Step 6: After Manage production click on edit release.
- Step 7: Now click on review.
- Step 8: After review click on Start Rollout to production.
24) What is date and time picker?
DatePicker
- Date picker is widget used to select a date.
- It allows to select data by day, month and year in your custom UI.
- Methods of
DatePicker
in invokesgetDayOfMonth()
,getMonth()
,getYear()
,getFirstDayOfWeek()
.
TimePicker
TimePicker
is a widget used for selecting the time of the day in either AM/PM mode or 24h mode.- The displayed time consist of hours, minutes and clock format.
- Methods of
TimePicker
invokessetCurrentHour()
,setHour()
,setCurrentMinute()
,getCurrentMinute()
.