Mad 200200107038
Mad 200200107038
B.E. Semester 7
Computer Engineering
Certificate
Place:
Date:
Main motto of any laboratory/practical/field work is for enhancing required skills as well as creating
ability amongst students to solve real time problem by developing relevant competencies in psychomotor
domain. By keeping in view, GTU has designed competency focused outcome-based curriculum for
engineering degree programs where sufficient weightage is given to practical work. It shows importance
of enhancement of skills amongst the students and it pays attention to utilize every second of time allotted
for practical amongst students, instructors and faculty members to achieve relevant outcomes by
performing the experiments rather than having merely study type experiments. It is must for effective
implementation of competency focused outcome-based curriculum that every practical is keenly designed
to serve as a tool to develop and enhance relevant competency required by the various industry among
every student. These psychomotor skills are very difficult to develop through traditional chalk and board
content delivery method in the classroom.
Accordingly, this lab manual is designed to focus on the industry defined relevant outcomes, rather than
old practice of conducting practical to prove concept and theory. By using this lab manual students can
go through the relevant theory and procedure in advance before the actual performance which creates an
interest and students can have basic idea prior to performance.
This in turn enhances pre-determined outcomes amongst students. Each experiment in this manual begins
with competency, industry relevant skills, course outcomes as well as practical outcomes (objectives).
The students will also achieve safety and necessary precautions to be taken while performing practical.
This manual also provides guidelines to faculty members to facilitate student centric lab activities
through each experiment by arranging and managing necessary resources in order that the students follow
the procedures with required safety and necessary precautions to achieve the outcomes. It also gives an
idea that how students will be assessed by providing rubrics. Utmost care has been taken while preparing
this lab manual however always there is chances of improvement. Therefore, we welcome constructive
suggestions for improvement and removal of errors if any.
There are a growing number of people who uses smartphones and tablets and hence mobile app
development has ability to access a large segment. Android has an advantage of being open source. This
course will enable the students to develop mobile application using Android.
CO2 Apply the knowledge to design user interface using Android UI A d Component
CO3 Manage system database, remote database operations using web services and Firebase
Apply knowledge of map, location services, Graphics, android system and background
CO4
services
Total
Mission:
✓ To produce computer science and engineering graduates according to the
needs of industry, government, society and scientific community.
✓ To develop partnership with industries, government agencies and R and D
Organizations
✓ To motivate students/graduates to be entrepreneurs.
✓ To motivate students to participate in reputed conferences, workshops,
symposiums, sem nars and related technical activities
→Activity_Practical1.xml
<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"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
tools:context=".MainActivity">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:elevation="36dp"
tools:ignore="UselessParent">
<TextView
android:id="@+id/tvName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/black"
android:textSize="15sp"
android:layout_marginStart="46dp"
android:layout_marginEnd="46dp"
android:layout_marginTop="10dp"/>
<TextView
android:id="@+id/tverno"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/tvName"
android:layout_marginStart="46dp"
android:layout_marginTop="10dp"
android:layout_marginEnd="46dp"
android:text="Er no : 180130107098"
android:textColor="@color/black"
android:textSize="15sp"
android:textStyle="normal" />
<TextView
android:id="@+id/tvaim1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Aim 1: Design Login activity and implement control events : Use EditText,
Checkbox and Buttons."
android:textColor="@color/black"
android:textStyle="normal"
android:textSize="15sp"
android:layout_marginStart="46dp"
android:layout_marginEnd="46dp"
android:layout_marginTop="10dp"/>
<TextView
android:id="@+id/tvaim2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/black"
android:layout_below="@id/tvaim1"
android:textStyle="normal"
android:textSize="15sp"
android:layout_marginStart="46dp"
android:layout_marginEnd="46dp"
android:layout_marginTop="10dp"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:id="@+id/llayout"
android:layout_marginLeft="46dp"
android:layout_centerVertical="true">
<com.google.android.material.textfield.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
app:startIconDrawable="@drawable/user"
android:id="@+id/tilId"
app:endIconMode="clear_text"
>
<com.google.android.material.textfield.TextInputEditText
android:padding="10dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/etId"
android:inputType="text"/>
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
app:startIconDrawable="@drawable/lock"
android:id="@+id/tilPassword">
<com.google.android.material.textfield.TextInputEditText
android:padding="10dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/etPassword"
android:inputType="textPassword"/>
</com.google.android.material.textfield.TextInputLayout>
<CheckBox
android:id="@+id/chBox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Remember Me?"
android:layout_marginTop="7dp"
android:buttonTint="@color/black"
/>
<TableLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TableRow
android:layout_width="match_parent"
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Need Help?"
android:layout_column="1"
android:textColor="@color/black"
/>
<Button
android:id="@+id/btnLogin"
android:layout_width="0200dp"
android:layout_marginStart="20dp"
android:layout_height="wrap_content"
android:layout_column="2"
android:text="LogIn"
android:layout_marginLeft="20dp" />
</TableRow>
</TableLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_alignParentBottom="true"
android:gravity="center"
android:padding="10dp"
>
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:textColor="@color/black"
android:layout_gravity="bottom"
android:layout_weight="1"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/black"
android:text="Register Instead."
android:layout_gravity="bottom"
android:textStyle="bold"
/>
</LinearLayout>
</RelativeLayout>
</LinearLayout>
5 package com.example.mad_practicals.Practical_1;
6
7
8
9 import androidx.appcompat.app.AppCompatActivity;
10
11
12
13 import android.os.Bundle;
14 import android.view.View;
15 import android.widget.Button;
16 import android.widget.CheckBox;
17 import android.widget.Toast;
18 import com.example.mad_practicals.R;
19
20 import com.google.android.material.textfield.TextInputEditText;
21 import java.util.Objects;
23 TextInputEditText etId;
24 TextInputEditText etPass;
25 Button btnSubmit;
26 CheckBox checkBox;
27 Button btnSS;
28 String check="";
29
30
31 @Override
32
33 protected void onCreate(Bundle savedInstanceState) {
34 super.onCreate(savedInstanceState);
35 setContentView(R.layout.activity_practical1);
etId=findViewById(R.id.etId);
etPass=findViewById(R.id.etPassword); checkBox
=findViewById(R.id.chBox);
btnSubmit.setOnClickListener(new View.OnClickListener() {
@Override
(!checkEmptyFields()) {
if(checkBox.isChecked()){
check="With Checkbox";
}else {
check="Without CheckBox";
Toast.makeText(getApplicationContext(),
Objects.requireNonNull(etId.getText()).toString() + " LoggedIN " + check,
Toast.LENGTH_LONG).show();
});
e=false;
if (Objects.requireNonNull(etId.getText()).toString().trim().isEmpty()){
e=true;
etId.setError(null);
if (Objects.requireNonNull(etPass.getText()).toString().trim().equals("")){
e=true;
}else {
etPass.setError(null);
return e;
Output:
RUBRICS 1 2 3 4 5 TOTAL
MARKS
<Button
android:id="@+id/btnURL"
android:layout_width="200dp"
android:layout_height="60dp"
android:text="Clich here"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/etUrl" />
</androidx.constraintlayout.widget.ConstraintLayout>
Activity_explicit_intent.xml
<?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=".Practical_3.ExplicitIntentActivity">
<Button
android:id="@+id/btnpre"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="50dp"
android:layout_marginLeft="50dp"
android:layout_marginTop="100dp"
android:text="GO back to Implicit Intent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<Button
android:id="@+id/btnnext"
android:layout_width="wrap_content"
Student Enrollment No :200200107038 Page 17 of 66
android:layout_height="wrap_content"
android:layout_marginEnd="50dp"
android:layout_marginRight="50dp"
android:layout_marginBottom="100dp"
android:text="Go next "
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
Activity_start_act_for_result1.xml
<?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"
tools:context=".Practical_3.StartActForResult_1stActivity">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="15sp"
android:text="Hello"
android:textStyle="normal"
android:textColor="@color/black"
android:padding="10dp"
android:gravity="center"
android:layout_marginTop="100dp"
android:id="@+id/tvDisplay"/>
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Get Message From Another activity"
android:id="@+id/btnDisplay"
android:layout_marginTop="50dp"
android:layout_marginStart="52dp"
android:layout_marginEnd="52dp"/>
</LinearLayout>
Activity_start_act_for_result2.xml
<?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:gravity="center"
android:orientation="vertical"
tools:context=".Practical_3.StartActForResult_2Activity">
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
Student Enrollment No :200200107038 Page 18 of 66
android:id="@+id/etSend"
android:hint="Enter a string"
android:padding="10dp"
android:textColor="@color/black"
/>
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Send String"
android:layout_marginTop="20dp"
android:id="@+id/btnSend"
/>
</LinearLayout>
Activity_third_Practical.xml
<?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=".Practical_3.ThirdPractical"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:elevation="36dp"
tools:ignore="UselessParent">
<androidx.appcompat.widget.Toolbar
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/toolBar3"
app:title="Practical 3"
android:background="@color/Green"
app:titleTextColor="@color/white"
/>
<TextView
android:id="@+id/tvName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Name: Pratik P shah"
android:textColor="@color/black"
android:layout_below="@id/toolBar3"
android:textStyle="normal"
android:textSize="15sp"
android:layout_marginStart="46dp"
android:layout_marginEnd="46dp"
android:layout_marginTop="10dp"/>
<TextView
android:id="@+id/tverno"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Er no: 180130107098"
Student Enrollment No :200200107038 Page 19 of 66
android:textColor="@color/black"
android:layout_below="@id/tvName"
android:textStyle="normal"
android:textSize="15sp"
android:layout_marginStart="46dp"
android:layout_marginEnd="46dp"
android:layout_marginTop="10dp"/>
<TextView
android:id="@+id/tvaim1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Aim 3: Create Activities and implement following 1. Implicit intent 2. Explicit
Intent 3. Start Activity For Result"
android:textColor="@color/black"
android:layout_below="@id/tverno"
android:textStyle="normal"
android:textSize="15sp"
android:layout_marginStart="46dp"
android:layout_marginEnd="46dp"
android:layout_marginTop="10dp"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerInParent="true"
android:orientation="vertical"
android:layout_marginStart="46dp"
android:layout_marginEnd="46dp"
android:gravity="center"
>
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Implicit Intent"
android:id="@+id/btnImplicit"/>
<Button
android:layout_marginTop="10dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Explicit Intent"
android:id="@+id/btnExplicit"/>
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="StartActivityFOrResult"
android:layout_marginTop="10dp"
android:id="@+id/btnStartActivityFOrResult"/>
</LinearLayout>
</RelativeLayout>
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import com.example.mad_practicals.R;
Button btnPre;
Button btnNext;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_explicit_intent);
btnNext=findViewById(R.id.btnnext);
btnPre=findViewById(R.id.btnpre);
btnPre.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
startActivity(new Intent(ExplicitIntentActivity.this,ImplicitIntentActivity.class));
}
});
btnNext.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
startActivity(new
Intent(ExplicitIntentActivity.this,StartActForResult_1stActivity.class));
}
});
}
}
ImplicitIntentActivity.java
package com.example.mad_practicals.Practical_3;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import com.example.mad_practicals.R;
EditText etURL;
Button btnURL;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_implicit_intent);
etURL=findViewById(R.id.etUrl);
btnURL=findViewById(R.id.btnURL);
btnURL.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent=new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse(etURL.getText().toString()));
startActivity(intent);
}
});
}
}
StartActForResult_1Activity.java
package com.example.mad_practicals.Practical_3;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import com.example.mad_practicals.R;
TextView tvDisplay;
Button btnDisplay;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_start_act_for_result1st);
tvDisplay=findViewById(R.id.tvDisplay);
btnDisplay=findViewById(R.id.btnDisplay);
btnDisplay.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent=new
Intent(StartActForResult_1stActivity.this,StartActForResult_2Activity.class);
startActivityForResult(intent,2);
}
});
}
Student Enrollment No :200200107038 Page 22 of 66
@Override
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
if (requestCode==2){
String message=data.getStringExtra("message");
tvDisplay.setText(message);
}
super.onActivityResult(requestCode, resultCode, data);
}
}
StartActForResult_2Activity.java
package com.example.mad_practicals.Practical_3;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import com.example.mad_practicals.R;
EditText editText;
Button button;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_start_act_for_result2);
editText=findViewById(R.id.etSend);
button=findViewById(R.id.btnSend);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent=new Intent();
intent.putExtra("message",editText.getText().toString());
setResult(2,intent);
finish();
}
});
}
}
ThirdPractical.java
package com.example.mad_practicals.Practical_3;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
Button btn1;
Button btn2;
Button btn3;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_third_practical);
btn1=findViewById(R.id.btnImplicit);
btn2=findViewById(R.id.btnExplicit);
btn3=findViewById(R.id.btnStartActivityFOrResult);
btn1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent=new Intent(ThirdPractical.this,ImplicitIntentActivity.class);
startActivity(intent);
}
});
btn2.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent=new Intent(ThirdPractical.this,ExplicitIntentActivity.class);
startActivity(intent);
}
});
btn3.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent=new Intent(ThirdPractical.this,StartActForResult_1stActivity.class);
startActivity(intent);
}
});
}
}
Outpu
RUBRICS 1 2 3 4 5 TOTAL
MARKS
activity_main.xml
File: activity_main.xml
1. <?xml version="1.0" encoding="utf-8"?>
2. <android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.
com/apk/res/android"
3. xmlns:app="http://schemas.android.com/apk/res-auto"
4. xmlns:tools="http://schemas.android.com/tools"
5. android:layout_width="match_parent"
6. android:layout_height="match_parent"
7. tools:context="example.javatpoint.com.optionmenu.MainActivity">
8.
9. <android.support.design.widget.AppBarLayout
10. android:layout_width="match_parent"
11. android:layout_height="wrap_content"
12. android:theme="@style/AppTheme.AppBarOverlay">
13.
14. <android.support.v7.widget.Toolbar
15. android:id="@+id/toolbar"
16. android:layout_width="match_parent"
17. android:layout_height="?attr/actionBarSize"
18. android:background="?attr/colorPrimary"
19. app:popupTheme="@style/AppTheme.PopupOverlay" />
20.
21. </android.support.design.widget.AppBarLayout>
22.
23. <include layout="@layout/content_main" />
24.
25. </android.support.design.widget.CoordinatorLayout>
File: context_main.xml
1. <?xml version="1.0" encoding="utf-8"?>
2. <android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/a
pk/res/android"
It contains three items as show below. It is created automatically inside the res/menu directory.
File: menu_main.xml
1. <menu xmlns:android="http://schemas.android.com/apk/res/android"
2. xmlns:app="http://schemas.android.com/apk/res-auto"
3. xmlns:tools="http://schemas.android.com/tools"
4. tools:context="example.javatpoint.com.optionmenu.MainActivity">
5.
6. <item android:id="@+id/item1"
7. android:title="Item 1"/>
8. <item android:id="@+id/item2"
9. android:title="Item 2"/>
10. <item android:id="@+id/item3"
11. android:title="Item 3"
12. app:showAsAction="withText"/>
13. </menu>
This class displays the content of menu.xml file and performs event handling on clicking the
menu items.
File: MainActivity.java
1. package example.javatpoint.com.optionmenu;
2.
3. import android.os.Bundle;
4. import android.support.v7.app.AppCompatActivity;
5. import android.support.v7.widget.Toolbar;
6. import android.view.Menu;
7. import android.view.MenuItem;
8. import android.widget.Toast;
9.
10. public class MainActivity extends AppCompatActivity {
11.
12. @Override
13. protected void onCreate(Bundle savedInstanceState) {
14. super.onCreate(savedInstanceState);
15. setContentView(R.layout.activity_main);
16. Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
17. setSupportActionBar(toolbar);
18. }
19.
20. @Override
21. public boolean onCreateOptionsMenu(Menu menu) {
22. // Inflate the menu; this adds items to the action bar if it is present.
23. getMenuInflater().inflate(R.menu.menu_main, menu);
24. return true;
25. }
26.
27. @Override
28. public boolean onOptionsItemSelected(MenuItem item) {
29. int id = item.getItemId();
30. switch (id){
31. case R.id.item1:
RUBRICS 1 2 3 4 5 TOTAL
MARKS
<ImageView
android:id="@+id.studentPhoto"
android:layout_width="64dp"
android:layout_height="64dp"
android:contentDescription="Student Photo" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical">
<TextView
android:id="@+id.studentName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="18sp" />
<TextView
android:id="@+id.studentAddress"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="14sp" />
</LinearLayout>
<Button
android:id="@+id.deleteButton"
android:layout_width="wrap_content"
android:layout_height="64dp"
android:text="Delete" />
</LinearLayout>
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import com.squareup.picasso.Picasso;
import java.util.List;
@NonNull
@Override
public StudentViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
View view = LayoutInflater.from(context).inflate(R.layout.item_student, parent, false);
return new StudentViewHolder(view);
}
Student Enrollment No :200200107038 Page 32 of 66
@Override
public void onBindViewHolder(@NonNull StudentViewHolder holder, int position) {
Student student = studentList.get(position);
holder.studentName.setText(student.getName());
holder.studentAddress.setText(student.getAddress());
// Load the student photo using Picasso (update with your image loading library)
Picasso.get().load(student.getPhotoUrl()).into(holder.studentPhoto);
holder.deleteButton.setOnClickListener(v -> {
onDeleteClickListener.onDeleteClick(position);
});
}
@Override
public int getItemCount() {
return studentList.size();
}
import android.os.Bundle;
import android.widget.Toast;
import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import java.util.ArrayList;
import java.util.List;
recyclerView = findViewById(R.id.recyclerView);
recyclerView.setLayoutManager(new LinearLayoutManager(this));
recyclerView.setAdapter(studentAdapter);
}
}
RUBRICS 1 2 3 4 5 TOTAL
MARKS
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:text="@string/team_1"/>
<ImageButton
android:id="@+id/decreaseTeam1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_centerVertical="true"
android:contentDescription="@string/minus_button"
android:src="@drawable/ic_minus" />
<TextView
android:id="@+id/score_1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text="@string/initial_count"/>
<ImageButton
android:id="@+id/increaseTeam1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:contentDescription="@string/plus_button"
android:src="@drawable/ic_plus"/>
Student Enrollment No :200200107038 Page 35 of 66
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:text="@string/team_2"/>
<ImageButton
android:id="@+id/decreaseTeam2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_centerVertical="true"
android:contentDescription="@string/minus_button"
android:src="@drawable/ic_minus"/>
<TextView
android:id="@+id/score_2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text="@string/initial_count"/>
<ImageButton
android:id="@+id/increaseTeam2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:contentDescription="@string/plus_button"
android:src="@drawable/ic_plus"/>
</RelativeLayout>
</LinearLayout>
/**
* Method that handles the onClick of both the decrement buttons
* @param view The button view that was clicked
*/
public void decreaseScore(View view) {
//Get the ID of the button that was clicked
int viewID = view.getId();
switch (viewID){
//If it was on Team 1
case R.id.decreaseTeam1:
//Decrement the score and update the TextView
Student Enrollment No :200200107038 Page 36 of 66
mScore1--;
mScoreText1.setText(String.valueOf(mScore1));
break;
//If it was Team 2
case R.id.decreaseTeam2:
//Decrement the score and update the TextView
mScore2--;
mScoreText2.setText(String.valueOf(mScore2));
}
}
/**
* Method that handles the onClick of both the increment buttons
* @param view The button view that was clicked
*/
public void increaseScore(View view) {
//Get the ID of the button that was clicked
int viewID = view.getId();
switch (viewID){
//If it was on Team 1
case R.id.increaseTeam1:
//Increment the score and update the TextView
mScore1++;
mScoreText1.setText(String.valueOf(mScore1));
break;
//If it was Team 2
case R.id.increaseTeam2:
//Increment the score and update the TextView
mScore2++;
mScoreText2.setText(String.valueOf(mScore2));
}
}
Output
RUBRICS 1 2 3 4 5 TOTAL
MARKS
</LinearLayout>
import android.content.ContentValues;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
// this method is called to check if the table exists already.
db.execSQL("DROP TABLE IF EXISTS " + TABLE_NAME);
onCreate(db);
}
}
import androidx.appcompat.app.AppCompatActivity;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// below line is to add on click listener for our add course button.
addCourseBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Output
RUBRICS 1 2 3 4 5 TOTAL
MARKS
<TextView
android:id="@+id/textview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="32dp"
android:text="Shared Preferences Demo"
android:textColor="@android:color/black"
android:textSize="24sp" />
<!--EditText to take the data from the user and save the
data in SharedPreferences-->
<EditText
android:id="@+id/edit1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/textview"
android:layout_marginStart="16dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="16dp"
android:hint="Enter your Name"
android:padding="10dp" />
<!--EditText to take the data from the user and save the
data in SharedPreferences-->
<EditText
android:id="@+id/edit2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/edit1"
android:layout_marginStart="16dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="16dp"
android:hint="Enter your Age"
android:inputType="number"
android:padding="10dp" />
</RelativeLayout>
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
name = findViewById(R.id.edit1);
age = findViewById(R.id.edit2);
}
Output
RUBRICS 1 2 3 4 5 TOTAL
MARKS
<LinearLayout
android:id="@+id/linearLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:orientation="vertical"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="1.0"
tools:ignore="MissingConstraints">
<TextView
android:id="@+id/textView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="170dp"
android:fontFamily="@font/roboto"
android:text="@string/heading"
android:textAlignment="center"
android:textAppearance="@style/TextAppearance.AppCompat.Large"
android:textColor="@android:color/holo_green_dark"
android:textSize="36sp"
android:textStyle="bold" />
<Button
android:id="@+id/startButton"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginStart="20dp"
android:layout_marginTop="10dp"
android:layout_marginEnd="20dp"
android:layout_marginBottom="20dp"
android:background="#4CAF50"
android:fontFamily="@font/roboto"
android:text="@string/startButtonText"
android:textAlignment="center"
Student Enrollment No :200200107038 Page 48 of 66
android:textAppearance="@style/TextAppearance.AppCompat.Display1"
android:textColor="#FFFFFF"
android:textStyle="bold" />
<Button
android:id="@+id/stopButton"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginStart="20dp"
android:layout_marginTop="10dp"
android:layout_marginEnd="20dp"
android:layout_marginBottom="20dp"
android:background="#4CAF50"
android:fontFamily="@font/roboto"
android:text="@string/stopButtonText"
android:textAlignment="center"
android:textAppearance="@style/TextAppearance.AppCompat.Display1"
android:textColor="#FFFFFF"
android:textStyle="bold" />
<ImageView
android:id="@+id/imageView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="80dp"
app:srcCompat="@drawable/banner" />
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
import android.app.Service;
import android.content.Intent;
import android.media.MediaPlayer;
import android.os.IBinder;
import android.provider.Settings;
import androidx.annotation.Nullable;
@Override
@Override
@Nullable
@Override
public IBinder onBind(Intent intent) {
return null;
}
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate( savedInstanceState );
setContentView( R.layout.activity_main );
// assigning ID of startButton
// to the object start
start = (Button) findViewById( R.id.startButton );
// assigning ID of stopButton
// to the object stop
stop = (Button) findViewById( R.id.stopButton );
// process to be performed
// if start button is clicked
if(view == start){
// process to be performed
// if stop button is clicked
else if (view == stop){
}
}
}
Student Enrollment No :200200107038 Page 51 of 66
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.services_in_android">
<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>
<meta-data
android:name="preloaded_fonts"
android:resource="@array/preloaded_fonts" />
</application>
</manifest>
Output
RUBRICS 1 2 3 4 5 TOTAL
MARKS
<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/Theme.GetUserLocation">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
</manifest>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingBottom="120dp"
android:src="@drawable/gfgimage" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="sans-serif-black"
android:text="Latitude:" />
Student Enrollment No :200200107038 Page 54 of 66
<TextView
android:id="@+id/latTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Latitude will be here! "
android:textColor="#f5f5f5" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="sans-serif-black"
android:text="Longitude:" />
<TextView
android:id="@+id/lonTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Longitude will be here! "
android:textColor="#f5f5f5" />
</LinearLayout>
import android.Manifest;
import android.annotation.SuppressLint;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.location.Location;
import android.location.LocationManager;
import android.os.Bundle;
import android.os.Looper;
import android.provider.Settings;
import android.widget.TextView;
import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.app.ActivityCompat;
import com.google.android.gms.location.FusedLocationProviderClient;
import com.google.android.gms.location.LocationCallback;
import com.google.android.gms.location.LocationRequest;
import com.google.android.gms.location.LocationResult;
import com.google.android.gms.location.LocationServices;
import com.google.android.gms.tasks.OnCompleteListener;
import com.google.android.gms.tasks.Task;
// initializing
Student Enrollment No :200200107038 Page 55 of 66
// FusedLocationProviderClient
// object
FusedLocationProviderClient mFusedLocationClient;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
latitudeTextView = findViewById(R.id.latTextView);
longitTextView = findViewById(R.id.lonTextView);
mFusedLocationClient = LocationServices.getFusedLocationProviderClient(this);
@SuppressLint("MissingPermission")
private void getLastLocation() {
// check if permissions are given
if (checkPermissions()) {
// getting last
// location from
// FusedLocationClient
// object
mFusedLocationClient.getLastLocation().addOnCompleteListener(new
OnCompleteListener<Location>() {
@Override
public void onComplete(@NonNull Task<Location> task) {
Location location = task.getResult();
if (location == null) {
requestNewLocationData();
} else {
latitudeTextView.setText(location.getLatitude() +
"");
longitTextView.setText(location.getLongitude() +
"");
}
}
});
} else {
Student Enrollment No :200200107038 Page 56 of 66
Toast.makeText(this, "Please turn on" + " your location...",
Toast.LENGTH_LONG).show();
Intent intent = new
Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
startActivity(intent);
}
} else {
// if permissions aren't available,
// request for permissions
requestPermissions();
}
}
@SuppressLint("MissingPermission")
private void requestNewLocationData() {
// Initializing LocationRequest
// object with appropriate methods
LocationRequest mLocationRequest = new LocationRequest();
mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
mLocationRequest.setInterval(5);
mLocationRequest.setFastestInterval(0);
mLocationRequest.setNumUpdates(1);
// setting LocationRequest
// on FusedLocationClient
mFusedLocationClient = LocationServices.getFusedLocationProviderClient(this);
mFusedLocationClient.requestLocationUpdates(mLocationRequest, mLocationCallback,
Looper.myLooper());
}
@Override
public void onLocationResult(LocationResult locationResult) {
Location mLastLocation = locationResult.getLastLocation();
latitudeTextView.setText("Latitude: " + mLastLocation.getLatitude() + "");
longitTextView.setText("Longitude: " + mLastLocation.getLongitude() + "");
}
};
// method to check
// if location is enabled
private boolean isLocationEnabled() {
LocationManager locationManager = (LocationManager)
getSystemService(Context.LOCATION_SERVICE);
return locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER) ||
locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER);
}
if (requestCode == PERMISSION_ID) {
if (grantResults.length > 0 && grantResults[0] ==
PackageManager.PERMISSION_GRANTED) {
getLastLocation();
}
}
}
@Override
public void onResume() {
super.onResume();
if (checkPermissions()) {
getLastLocation();
}
}
}
Output
RUBRICS 1 2 3 4 5 TOTAL
MARKS
<ImageView
android:id="@+id/imageview"
android:layout_width="200dp"
android:layout_height="200dp"
android:layout_centerHorizontal="true"
android:layout_marginTop="40dp"
android:contentDescription="@string/app_name"
android:src="@drawable/gfgimage" />
<LinearLayout
android:id="@+id/linear1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/imageview"
android:layout_marginTop="30dp"
android:orientation="horizontal"
android:weightSum="3">
</LinearLayout>
<LinearLayout
android:id="@+id/linear2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/linear1"
android:layout_marginTop="30dp"
android:orientation="horizontal"
android:weightSum="3">
</LinearLayout>
</RelativeLayout>
<alpha
android:duration="1000"
android:fromAlpha="1"
android:startOffset="2000"
android:toAlpha="0" />
Student Enrollment No :200200107038 Page 62 of 66
</set>
<translate
android:fromXDelta="0%p"
android:toXDelta="75%p"
android:duration="700" />
</set>
<rotate
android:duration="6000"
android:fromDegrees="360"
android:pivotX="50%"
android:pivotY="50%"
android:startOffset="5000"
android:toDegrees="0" />
</set>
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:fillAfter="true" >
<scale
android:duration="500"
android:fromXScale="1.0"
android:fromYScale="1.0"
android:interpolator="@android:anim/linear_interpolator"
android:toXScale="1.0"
android:toYScale="0.0" />
</set>
<scale
Student Enrollment No :200200107038 Page 63 of 66
android:interpolator="@android:anim/linear_interpolator"
android:duration = "1000"
android:fromXScal = "1"
android:fromYScale = "1"
android:pivotX = "50%"
android:pivotY = "50%"
android:toXScale = "2"
android:toYScale = "2"/>
</set>
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.Button;
import android.widget.ImageView;
ImageView imageView;
Button blinkBTN, rotateBTN, fadeBTN, moveBTN, slideBTN, zoomBTN, stopBTN;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
imageView = findViewById(R.id.imageview);
blinkBTN = findViewById(R.id.BTNblink);
rotateBTN = findViewById(R.id.BTNrotate);
fadeBTN = findViewById(R.id.BTNfade);
moveBTN = findViewById(R.id.BTNmove);
slideBTN = findViewById(R.id.BTNslide);
zoomBTN = findViewById(R.id.BTNzoom);
stopBTN = findViewById(R.id.BTNstop);
blinkBTN.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// To add blink animation
Animation animation =
AnimationUtils.loadAnimation(getApplicationContext(), R.anim.blink_animation);
imageView.startAnimation(animation);
}
});
rotateBTN.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// To add rotate animation
Animation animation =
Student Enrollment No :200200107038 Page 64 of 66
AnimationUtils.loadAnimation(getApplicationContext(), R.anim.rotate_animation);
imageView.startAnimation(animation);
}
});
fadeBTN.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// To add fade animation
Animation animation =
AnimationUtils.loadAnimation(getApplicationContext(), R.anim.fade_animation);
imageView.startAnimation(animation);
}
});
moveBTN.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// To add move animation
Animation animation =
AnimationUtils.loadAnimation(getApplicationContext(), R.anim.move_animation);
imageView.startAnimation(animation);
}
});
slideBTN.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// To add slide animation
Animation animation =
AnimationUtils.loadAnimation(getApplicationContext(), R.anim.slide_animation);
imageView.startAnimation(animation);
}
});
zoomBTN.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// To add zoom animation
Animation animation =
AnimationUtils.loadAnimation(getApplicationContext(), R.anim.zoom_animation);
imageView.startAnimation(animation);
}
});
stopBTN.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// To stop the animation going on imageview
imageView.clearAnimation();
}
});
}
}
RUBRICS 1 2 3 4 5 TOTAL
MARKS