0% found this document useful (0 votes)
48 views28 pages

Mad ct1 Q.B Ans

The document discusses various topics related to Android including features of Android OS, versions of Android, components of the Android ecosystem, uses of activities and services, absolute layouts, Android directory structure, emulators, members of OHA, the Android SDK, UI layouts used in design, components of AVD, views and viewgroups, and attributes of EditText. A total of 13 questions are answered covering these topics.

Uploaded by

mbhoomi23
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
48 views28 pages

Mad ct1 Q.B Ans

The document discusses various topics related to Android including features of Android OS, versions of Android, components of the Android ecosystem, uses of activities and services, absolute layouts, Android directory structure, emulators, members of OHA, the Android SDK, UI layouts used in design, components of AVD, views and viewgroups, and attributes of EditText. A total of 13 questions are answered covering these topics.

Uploaded by

mbhoomi23
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 28

22617 MAD QB CO6I 23-24

Q1. Attempt any Four of the following: 8


1) List features of Android Operating System.
Features of Android-
Open source
Powerful os
gsm technology
large user based
reduces development costs
application integration
media support
optimized graphics

2) List all versions of android operating system


Android versions-
Kitkat
marshmallow
Oreo
pie
cupcake
honeycomb
nougat
Ice cream sandwich
jelly bean
lollipop
Donut
Eclair
gingerbread
froyo
Android 10
Android 11
Android 12
Android 13
Android 14

3) Explain the components of android ecosystem


Google: It develops Android.
OEMs(Original Equipment Manufacturers):
They manufacture the hardware , and as well the custom application components.
Application Development Companies:
They are the major contributors to the ecosystem and employ Android developers, and also contract out
the product development to services companies.
Freelancer android developers:
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 playstore. Freelancer can also generate
money by developing applications for product companies.
4) Give the use of following components: i)Activities ii)Services
Activities are said to be the presentation layer of our applications. The UI of our application is build
around one or more extensions of the Activity class. By using Fragments and Views, activities set the
layout and display the output and also respond to the users actions.
An activity is implemented as a subclass of class Activity.
public class MainActivity extends Activity {
}
These are like invisible workers of our app. These components run at backend, updating your data
sources and Activities, triggering Notification and also broadcast Intents. They also perform some tasks
when applications are not active. A service can be used as a subclass of class Service:
public class ServiceName extends Service {
}

5) What is absolute layout.


An Absolute Layout lets you specify exact locations (x/y coordinates) of its children. Absolute layouts are
less flexible and harder to maintain than other types of layouts without absolute positioning.
Absolute Layout Attributes
1. android:id
This is the ID which uniquely identifies the layout.
2. android:layout_x
This specifies the x-coordinate of the view.
3. android:layout_y
This specifies the y-coordinate of the view.

6) List the components of Android directory structure.


7) Define Emulator.
1. An android SDK comes with a virtual mobile device emulator that runs on your computer. The emulator
enables us trial product, to develop and test Android applications without using a physical device.
2. An android emulator mimics all of the hardware and software features of typical mobile devices,
except that it can not place actual phone calls.
3. The android emulator runs on a full Android system stack, down to the kernel level, including a set of
preinstalled applications. We can select version of android system, we can modify mobile device skin
and key mapping.
4. It offers dynamic binary translation of device machine code to the OS and processor architecture of
your development machine.

8) Explain the members of OHA.


The Open Handset Alliance (OHA) is a consortium of various companies collaborating to develop open
standards for mobile devices, particularly focusing on the Android operating system. Here's an overview
of the types of companies that typically make up the OHA:

1. Hardware Companies: These are companies that manufacture hardware components for
smartphones and other mobile devices. This includes companies like Samsung, HTC, LG, Motorola,
Sony, and others. They contribute by producing Android-powered devices, including smartphones,
tablets, wearables, and other gadgets.

2. Software Companies: These companies develop software applications, middleware, and other
solutions that run on the Android platform. They may provide tools for app development, security
solutions, productivity software, and various other applications. Examples include Google (which
develops the Android operating system itself), as well as other software companies that create apps for
the Android ecosystem.

3. Handset Manufacturers: These are companies that specialize in designing, manufacturing, and
distributing mobile handsets. They produce a variety of devices, ranging from entry-level smartphones to
flagship models with advanced features. Examples include Samsung, Xiaomi, OnePlus, Huawei, and
many others.

4. Mobile Operators (Carriers): These are telecommunications companies that provide mobile network
services to consumers. They offer cellular connectivity, data plans, and other services to users of
Android devices. Examples include T-Mobile, Verizon, AT&T, Vodafone, and others. Mobile operators
may also work closely with handset manufacturers to offer subsidized devices and exclusive deals to
their customers.

5. Semiconductor Companies: These companies design and manufacture semiconductor chips,


including processors, memory chips, and other components used in mobile devices. They play a critical
role in the development of hardware for Android devices. Examples include Qualcomm, MediaTek, Intel,
and Samsung Semiconductor.

6. Commercialization Companies: This category may include companies involved in various aspects of
commercializing Android devices, such as marketing, distribution, retail, and other related services.
These companies help bring Android-powered devices to market and promote their adoption among
consumers. Examples could include retail chains, marketing agencies, and distributors specializing in
mobile devices.
9) What is android SDK.
The android SDK(software development kit ) provides to test android applications, the API libraries,
sample code, developer tools, and tutorials which help you to build, test and debug apps for Android.

Android SDK is made up of two main parts: the tools and packages. When you first install the SDK,
all you obtain are basic tools. These are executable and supporting files that help you develop
applications. The packages are the records specific to a particular version of android(called a platform)
or a particular add-on to a platform.

10) Enlist different types of layout used in UI design.


1. Linear Layout
LinearLayout is a view group that aligns all children in a single direction, vertically or horizontally.
2. Relative Layout
RelativeLayout is a view group that displays child views in relative positions.
3. Table Layout
TableLayout is a view that groups views into rows and columns.
4. Absolute Layout
AbsoluteLayout enables you to specify the exact location of its children.
5. Frame Layout
The FrameLayout is a placeholder on screen that you can use to display a single view.
6. Constraint Layout
Positions and sizes views using constraints, allowing for flexible and responsive designs.
7. Grid Layout
Organizes child views in a grid, specifying rows and columns.
8. Coordinator Layout
A flexible layout manager for coordinating the animations and transitions between child views.
9. ScrollView
Provides a scrollable view container for its child views.

11) List components of AVD.


An AVD consists of-
1. A hardware profile: Defines the hardware features of the virtual device. For ex. We can describe
whether the device has camera, whether it uses QWERTY keyboard, dialing pad, how much memory
it have on it.
2. A mapping to a system image: You can define what version of the android platform will run on
the virtual machine.
3. Skin: We can specify the emulator skin you want to use with the AVD, which lets you to control
the screen dimensions, look and so on.
4. Storage Area: A dedicated storage area on your development machine: the device’s user data(
installed applications, settings etc) and emulated SD card are stored in this area.
5. AVD and app features: Be sure our AVD definition includes the device features our app depends
on.
12) Explain view and viewgroup
● Views: Views are the base class for all visual interface elements (commonly known as controls or
widgets). All UI controls, including the layout classes, are derived from view.
● View Groups: View Groups are extensions of the View class that can contain multiple child Views.
Extend the ViewGroup class to create compound controls made up of interconnected child Views. The
ViewGroup class is also extended to provide the layout managers that help you lay out controls within
your Activities.

13)Name any four attributes of Edit Text control.


1. android:hint:
Sets the hint text that appears when the EditText is empty to provide context or instructions.
2. android:inputType:
Defines the type of data the EditText should accept (e.g., text, number, email).
3. android:maxLength:
Specifies the maximum number of characters allowed in the EditText.
4. android:password:
If set to true, hides the entered text for password input.

Q2. Attempt any Three of the following: 12


1) Draw and explain android architecture in detail.
Android operating system is a stack of software components which is roughly divided into five sections
and four main layers as shown below in the architecture diagram.
It includes operating system, middleware and important applications.
Each layer in the architecture provides different services.
1. Application
2. Application Framework
3. Libraries
4. Android Runtime.
5. Linux Kernel.
1. Application:
All application in application layer are written in Java Language. The various core applications that an
android device provides include
● Email client
● SMS program
● Maps
● Browser
● Calender
● Contacts
2.Application Framework
The Application Framework layer provides many higher-level services to applications in the form of Java
classes. Application developers are allowed to make use of these services in their applications.
Following are components in this layer-
1. Activity Manager: This layer manages the lifecycle of application and provides a common navigation
backstack.
2.Windows Manager: As the name suggest it manages the window surface. Then it organizes the screen
layout and locates the drawing surface and also perform windows related jobs.
3.View Manager: Views the window.
4.contents Manager: Enables application to access data from other applications or to share their own data.
5. Notification Manager: we get the notification from the system when battery is low. If the programmer
wants, he can enable all applications to display customer alerts in the status bar.
6.Package Manager: this manages the other packages if it is instant in the machine. Some times we
download some applications which is not own. This manages other packages.
7. Resource Manager − Provides access to non-code embedded resources such as strings, color
settings and user interface layout.
8. Location Manager: this manager helps to locate the mobile devices at which the location of the mobile
device can be searched . eg. Map, GPS or cell tower.
9. XMPP service Manager: Every mobile has some service like music application. Browser, ringtone,
services etc. It is managed by service manager.
3.Linux Kernel:
At the bottom of the layers is Linux Kernel. This provides a level of abstraction between
the device hardware and it contains all the essential hardware drivers like camera, keypad,
display etc. Also, the kernel handles all the things as networking and a vast array of device
drivers. Following are the drivers.
Display, Camera, Bluetooth, Flash Memory Driver, USB, WiFi, Keypad driver, Audio
Driver, Power Management Driver.
4. Libraries :
It is written in C/C++ libraries. This layer is communicated through application framework layer. The
communication happens through Java Native Interface(JNI) package. This layer contents 9 major
components.
● Surface Manager: Activity Manager, Windows Manager,View Manager.
● Open GLIES :provide 3D graphics libraries.
● SQLite database
● Media Framework Multimedia action which include sound, video audio
● SGL(Scalable graphics libraries): for implementing low level graphics using JNI
● Free Type : responsible for font quality,image(bitmap)
● SSL(Secured Socket Layer)
● Webkit:for giving browser support,it also support
Javascript,JQuery,HTML,CSS,Ajax
● Lib c(C libraries)
5.Android Runtime:
It consist of Dalvik Virtual Machines and Core Libraries.
● DVM(Dalvik Virtual Machines):
1. It is type of JVM used in android devices to run apps and is optimized for low processing power and
low memory environments.
2. Unlike JVM, the Dalvik virtual Machine does not run .class files, instead it runs .dex files.
3. .dex files are built from .class file at the time of compilation and provide higher efficiency in low
resource environments.
4. The DVM allows memory management, security, isolation and threading support.
● Core Libraries
These libraries provide most of functionalities defined in the Java SE libraries.
Data Structure
File Access
Network Access
Utilities
Graphics.
2) Explain the need of android.
Need of Android:
1. Browser: the android browser is one of the best browsers on the mobile market. It
generally loads pages faster than safari or any other browser, has flash support and simply
does everything a browser should do.
2. Desktop: the android phone adds widgets to the desktop. the purpose for widgets
e.g. the facebook widget allows you to update your Facebook desktop.
People widget allows you to make possible different actions for different contacts right
from your desktop.
Message widget allow you to immediately see your email from the desktop.
3. Connectivity: on one page /desktop you could be able to have connecting devices tool
button.
+ Turn on/off Bluetooth
+Turn on/off Wifi
+Turn on/off GPS
+Turn on/off mobile network
4. Multi-Notification: android phones have multi-notification system. With android the app
have access to the notification system and call all report.
5. Endless Personalization: the android cell phone allows client to configuration their
mobile to look and behave like they want.
6. Market: Android has an android market. The android apps are free and work as well.
7. Google Integration: the android has in build google support e.g google map ,gmail etc.
8. Open Source: the code of android OS as well as the apps is available.
9. Open to Carrier: If you know java then you can open android world.
10. Future: The future mobile phones are basically going to be smart phones.
3) Develop a program to implement linear layout using three buttons
XML file
<?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"
tools:context=".MainActivity"
android:orientation="vertical>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button 1"
android:id="@+id/bt1"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button 1"
android:id="@+id/bt2"/>
<Button
android:layout_width="wrap_content" add toast msg below
android:layout_height="wrap_content"
android:text="Button 1"
android:id="@+id/bt3"/>
</LinearLayout>

JAVA file
package com.example.ct1_1;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;

public class MainActivity extends AppCompatActivity {


@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button b1,b2,b3;
b1=findViewById(R.id.bt1);
b2=findViewById(R.id.bt2);
b3=findViewById(R.id.bt3);
b1.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View view){
Toast.makeText(MainActivity.this,"Button 1", Toast.LENGTH_LONG).show();
}
});
b2.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v){
Toast.makeText(MainActivity.this,"Button 2",Toast.LENGTH_SHORT).show();
}
});
b3.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v){
Toast.makeText(MainActivity.this,"Button 3",Toast.LENGTH_LONG).show();
}
});
}
}

4) Design a profile page using constraint layout.


XML file
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
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">

<ImageView
android:layout_width="250dp"
android:layout_height="250dp"
android:src="@drawable/me"
android:id="@+id/img"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:layout_marginTop="50dp"/>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Bhoomi Manuja"
android:id="@+id/name"
android:textSize="25sp"
app:layout_constraintTop_toBottomOf="@id/img"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
android:layout_marginTop="30dp"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="manujabhoomi@gmail.com"
android:id="@+id/email"
app:layout_constraintTop_toBottomOf="@id/name"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
android:layout_marginTop="10dp"/>

<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Click."
android:id="@+id/btn"
app:layout_constraintTop_toBottomOf="@id/email"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
android:layout_marginTop="20dp"/> add toast msg below

</androidx.constraintlayout.widget.ConstraintLayout>

JAVA file
package com.example.ct1_2;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;

public class MainActivity extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

Button b1;
b1=findViewById(R.id.btn);
b1.setOnClickListener(new View.OnClickListener(){

@Override
public void onClick(View v){
Toast.makeText(MainActivity.this, "You are viewing Bhoomi Manuja's profile.",
Toast.LENGTH_SHORT).show();
}
});
}
}

5) Differentiate JVM and DVM.

6) What is ADT ? Explain in detail.


ADT is a plugin for the eclipse IDE which provides a suitable environment to develop android
application where creation, compilation and debugging are possible.
ADT are able to set up new Android projects, create an android UI, insert packages based on the
Android Framework API,debug your application using the Android SDK tools and export signed(or
unsigned).apk files in order to distribute in the applications.

-Create a new android Application


-Compile and debug android applications
-Create digital certificate for code-singing of APK(Android application packages)
-Access the tools for accessing android emulators and devices.
-Create an application UI
7)Develop a program to implement relative layout using edittext and buttons
XML file
<?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">

<EditText
android:id="@+id/et"
android:ems="10"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint="Enter your text here"/>
<Button
android:id="@+id/bt1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/et"
android:text="Button 1"/>
<Button
android:id="@+id/bt2"
android:layout_width="wrap_content" add toast msg below
android:layout_height="wrap_content" textfield mein text daalke o/p likhna
android:layout_below="@id/bt1" vahi toast msg mein aayega kyuki phir
android:text="Button 2"/>
</RelativeLayout>

JAVA file
package com.example.ct1_3;
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 {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button b1,b2;
EditText text;
text=findViewById(R.id.et);
b1=findViewById(R.id.bt1);
b2=findViewById(R.id.bt2);
b1.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View view){
Toast.makeText(MainActivity.this,"Button 1 Clicked. Your Text-"+text.getText(),
Toast.LENGTH_LONG).show();
}
});
b2.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v){
Toast.makeText(MainActivity.this,"Button 2 Clicked. Your
Text-"+text.getText(),Toast.LENGTH_SHORT).show();
}
});
}
}

8) Develop a program to implement marksheet for student using Table layout


XML file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="16dp">

<TableLayout
android:id="@+id/tableLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:stretchColumns="*">
<TableRow>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Subject"
android:textStyle="bold"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Marks"
android:textStyle="bold"/>
</TableRow>
<TableRow>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="C"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="83"/>
</TableRow>
<TableRow>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="PHP"/>
<TextView
android:layout_width="wrap_content" add toast msg below
android:layout_height="wrap_content"
android:text="85"/>
</TableRow>
<TableRow>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Python
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="78"/>
</TableRow>
<TableRow>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="DSU"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="80"/>
</TableRow>
<TableRow>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="DBMS" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="76"/>
</TableRow>
</TableLayout>
<Button
android:id="@+id/cal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Show Percentage"/>

</LinearLayout>

JAVA file
package com.example.ct1_4;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;

import androidx.appcompat.app.AppCompatActivity;

public class MainActivity extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button b1;

b1 = findViewById(R.id.cal);
b1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(MainActivity.this, "Percentage: 80.4%", Toast.LENGTH_SHORT).show();
}
});
}
}

9) Develop a program to implement Framelayout which shows different oops datatypes


XML file
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout 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"
tools:context=".MainActivity">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="top|left"
android:text="Character"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="top|right"
android:text="Boolean"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="Datatypes in Object-Oriented Programming"
android:id="@+id/layout"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|left"
android:text="Integer"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|right" ` add toast msg below
android:text="Floating Point"/>
</FrameLayout>

JAVA file
package com.example.ct1_5;
import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;

public class MainActivity extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
TextView t1;
t1=findViewById(R.id.layout);
t1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Toast.makeText(MainActivity.this, "Layout: Frame Layout.", Toast.LENGTH_SHORT).show();
}
});
}
}

10)Write a program to accept and display personal information of student.


XML file
<?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"
tools:context=".MainActivity"
android:orientation="vertical">

<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:hint="Enter Name"
android:id="@+id/name"/>
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:hint="Enter Age" add toast msg below
android:id="@+id/age"/> textfields mein naam, age daalke o/p likhna
<Button vahi toast msg mein aayega kyuki phir
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Display"
android:id="@+id/btn"/>
</LinearLayout>

JAVA file
package com.example.ct1_6;

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 {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button b1;
EditText n,a;
n=findViewById(R.id.name);
a=findViewById(R.id.age);
b1=findViewById(R.id.btn);
b1.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View view){
Toast.makeText(MainActivity.this,"Name: "+n.getText()+", Age: "+a.getText(),
Toast.LENGTH_LONG).show();
}
});
}
}

11)write a program to accept username and password from user using textview and edittext.
XML file
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
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">

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/user"
android:layout_marginTop="30dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="UserName"/>
<EditText
android:id="@+id/et1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:layout_toRightOf="@+id/user"/>
<TextView
android:id="@+id/pass"
android:layout_marginTop="30dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/user"
android:text="Password"/> add toast msg below
<EditText textfields mein naam, pass daalke o/p likhna
android:id="@+id/et2" vahi toast msg mein aayega kyuki phir
android:layout_marginTop="50dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@+id/pass"
android:ems="10"
android:inputType="textPassword"/>
<Button
android:id="@+id/btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/et2"
android:text="Submit"/>
</RelativeLayout>
</androidx.constraintlayout.widget.ConstraintLayout>

JAVA file
package com.example.ct1_8;

import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;

public class MainActivity extends AppCompatActivity {


EditText u,p;
Button b1;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
b1=findViewById(R.id.btn);
b1.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v) {
u=findViewById(R.id.et1);
p=findViewById(R.id.et2);
Toast.makeText(MainActivity.this,"UserName: "+u.getText()+", Password: "+p.getText(),
Toast.LENGTH_LONG).show();
}
});
}
}

12)write a program to display 3 student basic information in table form using tablelayout.
XML file
<?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">

<TextView
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="Student Information"
android:id="@+id/info"
android:textSize="20dp"/>

<TableLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/info"
android:id="@+id/tb">

<TableRow>
<TextView
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="SrNo." />
<TextView
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="Name"/>
<TextView
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="Age"/>
</TableRow>
<TableRow>
<TextView
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="1"/>
<TextView
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="ABC"/>
<TextView
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="17"/>
</TableRow>
<TableRow>
<TextView
android:layout_height="wrap_content" add Toast msg below
android:layout_width="wrap_content"
android:text="2"/>
<TextView
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="DEF"/>
<TextView
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="12"/>
</TableRow>
<TableRow>
<TextView
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="3"/>
<TextView
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="GHI"/>
<TextView
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="14"/>
</TableRow>
</TableLayout>

<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Click"
android:id="@+id/btn"
android:layout_below="@+id/tb"/>
</RelativeLayout>

JAVA file
package com.example.ct1_7;

import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;

public class MainActivity extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button b1;
b1=findViewById(R.id.btn);
b1.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View view){
Toast.makeText(MainActivity.this,"ABC is Oldest.", Toast.LENGTH_LONG).show();
}
});
}
}

13)write a program to place name, age and mobile number centrally on the display screen using
Absolute layout.
XML file
<?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="wrap_content"
android:layout_height="wrap_content"
tools:context=".MainActivity"
android:orientation="vertical"
android:layout_gravity="center"
tools:ignore="Deprecated">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="0dp"
android:layout_y="0dp"
android:text="Name: Bhoomi Manuja"
android:textSize="30sp"
android:layout_margin="20dp"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Age: 18"
android:textSize="30sp"
android:layout_margin="20dp"
android:layout_x="100dp"
android:layout_y="50dp"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Phone No.: 2383823932"
android:textSize="30sp"
android:layout_margin="20dp"
android:layout_x="0dp"
android:layout_y="100dp"/>
</AbsoluteLayout>

JAVA file
package com.example.ct1_9;
import androidx.appcompat.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);
}
}

14)write a program to create togglebutton to display on/off bluetooth on the display screen.
XML file
<?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">
<ToggleButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/toggleButton"
android:textOn="Bluetooth ON"
android:textOff="Bluetooth Off"/>
<ImageView
android:id="@+id/imageView"
android:layout_width="300dp"
android:layout_height="300dp"/>
</RelativeLayout>

JAVA file
package com.example.exp8_1;

import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.Toast;
import android.widget.ToggleButton;

public class MainActivity extends AppCompatActivity {


ToggleButton togglebutton;
ImageView imageview;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

togglebutton=findViewById(R.id.toggleButton);
imageview=findViewById(R.id.imageView);
imageview.setImageDrawable(getResources().getDrawable(R.drawable.bluetooth_on));
togglebutton.setOnClickListener(new View.OnClickListener() {

@Override
public void onClick(View v) {

if (togglebutton.isChecked())
imageview.setImageDrawable(getResources().getDrawable( R.drawable.bluetooth_off ));
else
imageview.setImageDrawable(getResources().getDrawable(R.drawable.bluetooth_on ));
}
});
}
}

SELECTOR.XML file
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_checked="true" android:drawable="@drawable/bluetooth_on"/>
<item android:state_checked="false" android:drawable="@drawable/bluetooth_off"/>
</selector>

15) write a program to create login form for social networking site.
XML file
<?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">

<TextView
android:id="@+id/login"
android:layout_marginTop="30dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="LOGIN PAGE"/>
<TextView
android:id="@+id/user"
android:layout_marginTop="60dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="UserName"/>
<EditText
android:id="@+id/et1"
android:layout_marginTop="30dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:layout_toRightOf="@+id/user"/> add toast msg below
<TextView
android:id="@+id/pass"
android:layout_marginTop="15dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/user"
android:text="Password"/>
<EditText
android:id="@+id/et2"
android:layout_marginTop="70dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@+id/pass"
android:ems="10"
android:inputType="textPassword"/>
<Button
android:id="@+id/btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/et2"
android:text="Submit"/>
</RelativeLayout>

JAVA file
package com.example.ct1_10;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;

public class MainActivity extends AppCompatActivity {


EditText u,p;
Button b1;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

b1=findViewById(R.id.btn);
b1.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v) {
u=findViewById(R.id.et1);
p=findViewById(R.id.et2);
Toast.makeText(MainActivity.this,"Logged in Successfully.", Toast.LENGTH_LONG).show();
}
});
}
}
16) Describe various installation steps of android studio and its environment.
Steps for installing Android Studio:
1. Go to the Android Studio website
2. Click Download Android Studio
3. Open the folder where you downloaded and saved the Android Studio installation (.exe) file.
4. Double-click the downloaded file.
5. If you see a User Account Control dialog about allowing the installation to make changes to your
computer, click Yes to confirm the installation.
6. Click Next to start the installation.
7. Run the downloaded executable file.
8. Choose the components.
9. Accept the default installation settings for all steps.
10. Install any recommended SDK packages.
11. Click Finish when the installation is done to launch Android Studio.
12. Download the latest SDK tools and SDK platforms using the Android SDK Manager.
13. Install updated packages if needed.

Steps for installing the Android environment:


1. Install Java
2. Uninstall older versions of JDK/JRE
3. Install the Android Studio IDE
4. Install the Android SDK
5. Set up the Android environment

17) Describe directory structure and its components.


Android Directory Structure:
The main objective of an android project is to build an .apk file from it.
/src – This is the most common folder in any android project. It contains our java source code for
android application.
/gen – In most IDE(such as Eclipse) this folder is created by IDE for configuration purpose. Under this
folder we can find two java files such as BuildConfig.java and R.java. Both files are auto generated by
IDE which helps android project to work smoothly.
/Android(version name) – Under this folder we can see some android.jar file which relates to android
sdk platform. We should not modify this file for smooth functioning of our project.
/assets – By default this folder is empty, but we can store raw asset files such as music file,data file etc
in this folder. The files retains its original name and structure when compiled into an .apk file.
/bin – This is a very important folder in our directory structure as it contains AndroidManifest.xml file and
serves as an output directory for our project which further builds an .apk file.
/libs – This folder contains private libraries.
/res – This folder contains lots of required sub folders for the project. Let’s understand these folders
one by one.
a) /drawable – Under this folder we store images(PNG,JPEG,GIF) for our project. Generally this
folder comes with five types of sub folders which ensures rendering of images on mobile devices
according to its screen resolution. There are five sub folders with different names such as:
drawable-hdpi,drawable-ldpi,drawable-mdpi,drawable-xhdpi,drawable-xxhdpi (where dpi refers to dot
per inch). Normally Google prefers .PNG format for images.
b) /layout – Under this folder we store UI layouts file for our android project, which is written
in xml format. we can store as many activity file under this folder. In other words this folder relates to
our application UI layouts.
c) /menu – For XML files that define application menus.
d) /values – In this folder we place predefined application values in the form of XML files that define
the variable names and their value that will be later referenced in our java source code. In simple
words, it holds all our constant values for our application in one place. In this way we can customize
our applications at one place as per our requirements. Within this folder we can find three xml files
such as:
i) dimens.xml: This XML file defines the dimension values such as font sizes and standard heights
for our UI.
ii) strings.xml: In this file we define text strings which is used in the application. for example: if we
wish to change the title of an application, then we can simply change in this file instead of doing any
hard coding in application.
iii) styles.xml: This XML file defines styles which is used in the application. Generally we apply
these styles to our UI elements. With the help of style we can separate the look of our application from
the layout and functionality.
/project.properties: This file contains project settings, such as the build target. We can edit project
properties in eclipse(IDE).

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy