Ap File
Ap File
Group of College
Practical File
System Requirements
Microsoft Windows 7/8/10 (32-bit or 64-bit)
4 GB RAM minimum, 8 GB RAM recommended (plus 1 GB for the
Android Emulator)
2 GB of available disk space minimum, 4 GB recommended (500
MB for IDE plus 1.5 GB for Android SDK and emulator system
image)
1280 x 800 minimum screen resolution
Installation Guide
Step 1: Get the Android Studio executable or zip file.
Step 3: After the downloading has finished, open the file from downloads
and run it. It will prompt the following dialog box. Click on next. In the
next prompt, it’ll ask for a path for installation. Choose a path and hit
next.
Step 5: Once “Finish” is clicked, it will ask whether the previous settings
need to be imported [if the android studio had been installed earlier], or
not. It is better to choose the ‘Don’t import Settings option’. Click the OK
button.
Step 7: After it has found the SDK components, it will redirect to the
Welcome dialog box. Click on Next. Choose Standard and click on Next.
Now choose the theme, whether the Light theme or the Dark one. The
light one is called the IntelliJ theme whereas the dark theme is called
Dracula. Choose as required. Click on the Next button.
The Android Studio has been successfully configured. Now it’s time to
launch and build apps. Click on the Finish button to launch it.
Step 9: Click on Start a new Android Studio project to build a new app.
PRACTICAL - 2
Android SDK Manager and all its components
Android SDK stands for Android Software Development Kit which is
developed by Google for Android Platform. With the help of Android
SDK, we can create android Apps easily.
• Android Emulator.
Android SDK build tools are used for building actual binaries of Android
App. The main functions of Android SDK Build tools are built, debug, run
and test Android applications. The latest version of the Android SDK
Build tool is 30.0.3. While downloading or updating Android in our
System, one must ensure that its latest version is download in SDK
Components.
3. Android Emulator
Thus, it simply means that without needing any physical device Android
SDK component “Android Emulator” provides a virtual device on the
System where we run our application. The emulator’s come with the
configuration for Various android phones, tablets, Wear OS, and Android
TV devices. In Android Virtual Emulator all functions that are feasible on
real Android mobile is works on virtual Device like:
In SDK Update Sites, some sites are embedded in it which will check for
Android SDK Updates Tools. In this, one must ensure we don’t unclick
the button below because these are checked by default which will check
for updates if we will unclick it then it doesn’t check updates for those.
PRACTICAL - 3
Programs based on overriding, constructor, classes in java
Method Overriding in Java
class Vehicle{
obj.run();
Output
Vehicle is running
Constructors in Java
class Student4{
int id;
String name;
id = i;
name = n;
s1.display();
s2.display();
Output
111 Karan
222 Aryan
Java Classes
class Student {
int id;
String name;
System.out.println(s1.id);
System.out.println(s1.name);
Output
Null
PRACTICAL - 4
Program based on the final, this and static keyword in java
final keyword in java
class Bike9{
void run(){speedlimit=400;
obj.run();
Output:
class Bike{
honda.run();
}
Output
int rollno;
String name;
float fee;
this.rollno=rollno;
this.name=name;
this.fee=fee;
class TestThis2{
s1.display();
s2.display();
}}
Output:
static {
System.out.println("from m1");
return 20;
System.out.println("Value of a : "+a);
System.out.println("from main");
Output
from m1
Value of a : 20
from main
PRACTICAL - 5
Directory structure of an Android Project Common default
resources folders, the value folder, leveraging android
XML.
An android project is a combination of required files and folders which
further builds a directory to complete any android application. As android
is a most popular open source mobile platform so the need of the
android applications is growing very rapidly. In this article I explained the
directory structure for any android project. The directory structure is a
foundation of any android project. It acts like a container which holds
necessary logics, images, customization in its real form. During the
generation(compilation) of a project, android looks into these folder to
locate each type of assets it needs.
• Android Projects
• Test Projects
• Library Projects
The main objective of an android project is to build an .apk file from it.
And for this when we start with an android project then some directories
create by default and some needs few customization to enhance android
applications. So, let’s understand the directory structure in android
project to develop an android application.
/src – This is the most common folder in any android project. It contains
our java source code for android application. Under this folder we can
see our java source files in which we write logic for android applications.
/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.
/res – This folder contains lots of required sub folders for the project.
Let’s understand these folders one by one
PRACTICAL - 6
Applications based on Text Boxes and Button
Android Button represents a push-button. The android.widget.Button is
subclass of TextView class and CompoundButton is the subclass of Button
class. There are different types of buttons in android such as RadioButton,
ToggleButton, CompoundButton etc.
Here, we are going to create two textfields and one button for sum of two
numbers. If user clicks button, sum of two input values is displayed on the
Toast. button.setOnClickListener(new View.OnClickListener() { @Override
//code
});
<Button
android:onClick="methodName"
/>
First of all, drag 2 textfields from the Text Fields palette and one button from
the Form Widgets palette as shown in the following figure.
<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="example.javatpoint.com.sumoftwonumber.MainActivity">
<EditText android:id="@+id/editText1"
android:layout_width="wrap_content"android:layout_height="wrap_content"
android:layout_alignParentTop="true"android:layout_centerHorizontal="true"
android:layout_marginTop="61dp"
android:ems="10"
android:inputType="nu="number"tools:layout_editor_absoluteX="84dp"
tools:layout_editor_absoluteY="53dp" />
<EditText android:id="@+id/editText2"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:layout_below="@+id/
editText1"android:layout_centerHorizontal="true"android:layout_marginTop="
32dp" android:ems="10" android:inputType="number"
tools:layout_editor_absoluteX="84dp"
tools:layout_editor_absoluteY="127dp" />
<Button android:id="@+id/button"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:layout_below="@+id/editText2"android:layout_centerHorizontal="true"
android:layout_marginTop="109dp" android:text="ADD"
tools:layout_editor_absoluteX="148dp" tools:layout_editor_absoluteY="266dp"
/>
</RelativeLayout>
PRACTICAL - 7
Applications based on Check Boxes and button
Android CheckBox is a type of two state button either checked or
unchecked.
Method Description
Returns true if it is checked
public boolean isChecked() otherwise
false
public void setChecked(boolean Changes the state of the
status) CheckBox.
<android.support.constraint.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="example.javatpoint.com.checkbox.MainActivity">
<CheckBox android:id="@+id/checkBox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="144dp" android:layout_marginTop="68dp"
android:text="Pizza"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
/>
<CheckBox android:id="@+id/checkBox2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="144dp"
android:layout_marginTop="28dp" android:text="Coffee
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/checkBox" />
<CheckBox
android:id="@+id/checkBox3" android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="144dp"
android:layout_marginTop="28dp" android:text="Burger"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/checkBox2" />
<Button android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="144dp" android:layout_marginTop="184dp"
android:text="Order" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/checkBox3" />
</android.support.constraint.ConstraintLayout>
Activity class
package example.javatpoint.com.checkbox;
android.widget.Toast;
setContentView(R.layout.activity_main); addListenerOnButtonClick();
pizza=(CheckBox)findViewById(R.id.checkBox);
coffe=(CheckBox)findViewById(R.id.checkBox2);
burger=(CheckBox)findViewById(R.id.checkBox3);
buttonOrder=(Button)findViewById(R.id.button);
buttonOrder.setOnClickListener(new View.OnClickListener(){
if(pizza.isChecked()){
result.append("\nTotal: "+totalamount+"Rs");
result.toString(),
Toast.LENGTH_LONG).show();
});
}}