Вы находитесь на странице: 1из 77

SCHOOL OF COMPUTING

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

BONAFIDE CERTIFICATE

Bonafide record of work done by


of _ in
during even/odd semester in academic year

Staff In-charge Head of the Department

Submitted to the practical Examination held at Kalasalingam University, Krishnankoil on

________________________________

REGISTER NUMBER

Internal Examiner External Examiner

1
Experimental Evaluation Summary

Name: Reg.No:

Class: Faculty:

S.No Date Experiment Marks Faculty


(100) Signature
1 General Form Design

2 Mobile Browser based interactive


application

3 Application using Controls

4 Mobile Network
application(SMS/E-mail)

5 Application involving data


retrieval

6 Launching service in a mobile


phone

7 Web portal Development

8 Application using Android


Framework( Like interactive
application, application for make
use of accelerometer sensor,
video applications)

9 Applications that uses the iphone


SDK frame work

10 Testing the applications using


emulator

2
Ex.No:1 General Form Design

Date:

Aim: To design the general form design in Android studio.

Coding:

ACTIVITYMAIN.XML
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/bg"
tools:context=".MainActivity">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="28dp"
android:text="STUDENT FORM"
android:textColor="#000000"
android:layout_marginLeft="80dp"
android:layout_marginTop="70dp"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Name"
android:textColor="#000000"
android:textSize="25dp"
android:layout_marginTop="150dp"

/>

<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="200dp"
android:id="@+id/name"
/>
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Department"
android:textColor="#000000"

3
android:textSize="25dp"
android:layout_marginTop="250dp"

/>

<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="300dp"
android:id="@+id/department"
/>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="RegisterNumber"
android:textColor="#000000"
android:textSize="25dp"
android:layout_marginTop="350dp"

/>

<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="400dp"
android:id="@+id/regno"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="CGPA"
android:textColor="#000000"
android:textSize="25dp"
android:layout_marginTop="450dp"

/>

<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="500dp"
android:id="@+id/cgpa"
/>

<Button
android:layout_width="110dp"
android:layout_height="50dp"
android:layout_marginTop="600dp"
android:text="Submit"

4
android:layout_marginLeft="150dp"
android:onClick="Submit"
/>
</RelativeLayout>

ACTIVITY_DISPLAY.XML

<?xml version="1.0" encoding="utf-8"?>


<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/bg"
tools:context=".DisplayActivity">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="28dp"
android:text="Summary"
android:textColor="#000000"
android:layout_marginLeft="120dp"
android:layout_marginTop="70dp"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Name"
android:textColor="#000000"
android:textSize="25dp"
android:layout_marginTop="150dp"
/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="200dp"
android:id="@+id/dname"
android:textSize="30dp"
/>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Department"
android:textColor="#000000"
android:textSize="25dp"
android:layout_marginTop="250dp"
/>
<TextView
android:layout_width="match_parent"

5
android:layout_height="wrap_content"
android:layout_marginTop="300dp"
android:id="@+id/ddepartment"
android:textSize="25dp"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="RegisterNumber"
android:textColor="#000000"
android:textSize="25dp"
android:layout_marginTop="350dp"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="400dp"
android:id="@+id/dregno"
android:textSize="25dp"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="CGPA"
android:textColor="#000000"
android:textSize="25dp"
android:layout_marginTop="450dp"
/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="500dp"
android:id="@+id/dcgpa"
android:textSize="25dp"
/>
</RelativeLayout>

MAINACTIVITY.JAVA
package com.stn.formsstn;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.EditText;

public class MainActivity extends AppCompatActivity {


private EditText Studentname; //java object
private EditText Studentdept;
private EditText Studentcgpa;
private EditText Studentregno;

6
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Studentname=findViewById(R.id.name);
Studentdept=findViewById(R.id.department);
Studentregno = findViewById(R.id.regno);
Studentcgpa = findViewById(R.id.cgpa);
}

public void Submit(View view)


{
String sname = Studentname.getText().toString();
String sdept = Studentdept.getText().toString();
String sregno = Studentregno.getText().toString();
String scgpa = Studentcgpa.getText().toString();

Intent i = new Intent(MainActivity.this,DisplayActivity.class);

i.putExtra("name",sname);
i.putExtra("dept",sdept);
i.putExtra("regno",sregno);
i.putExtra("cgpa",scgpa);
startActivity(i);
}

DISPLAYACTIVITY.JAVA
package com.stn.formsstn;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.TextView;

public class DisplayActivity extends AppCompatActivity {


TextView tv1,tv2,tv3,tv4;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_display_actvity);
tv1=findViewById(R.id.dname);
tv2=findViewById(R.id.ddepartment);
tv3=findViewById(R.id.dregno);
tv4=findViewById(R.id.dcgpa);

tv1.setText(""+getIntent().getStringExtra("name"));

7
tv2.setText(""+getIntent().getStringExtra("dept"));
tv3.setText(""+getIntent().getStringExtra("regno"));
tv4.setText(""+getIntent().getStringExtra("cgpa"));

}
}

Output

8
EVALUATION

Sl.No Module Max. Marks Marks Obtained


1 XML design 20
2 Java code 20
3 Execution in Android 10
4 Output 20
5 Technical Skill 20
6 Communication Skill 10
Total 100

Faculty Signature

RESULT:

Thus the general form design program is executed successfully in Android studio.

9
Ex.No:2 Name: Mobile browser based interactive application

Date:

Aim: To design the Mobile browser based interactive application in Android studio.

Coding:

• Include Internet permission, to access the internet feature of the mobile. Add this permission
above the <application >tag.
<uses-permission android:name="android.permission.INTERNET"/>
ANDROIDMANIFEST.XML

<?xml version="1.0" encoding="utf-8"?>


<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.stn.exp2">
<uses-permission android:name="android.permission.INTERNET"/>
<application
//PREDEFINED CODE
</application>
</manifest>
ACTIVITY_MAIN.XML
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Clcik any text to visit website"
android:textColor="#000000"
android:textStyle="bold"
android:textAllCaps="true"
android:layout_marginTop="50dp"
android:layout_marginLeft="70dp"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="1. Google"
android:textColor="#000000"
android:layout_marginLeft="70dp"
android:layout_marginTop="100dp"

10
android:onClick="google"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="2.Facebook"
android:textColor="#000000"
android:layout_marginLeft="70dp"
android:layout_marginTop="150dp"
android:onClick="facebook"
/>
</RelativeLayout>

ACTIVITY_FACEBOOK.XML

<?xml version="1.0" encoding="utf-8"?>


<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=".facebook">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<WebView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/w2"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:usesCleartextTraffic="true"
/>
</LinearLayout>
</android.support.constraint.ConstraintLayout>

ACTIVITY_GOOGLE.XML

<?xml version="1.0" encoding="utf-8"?>


<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=".google">

11
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<WebView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/w1"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:usesCleartextTraffic="true"
/>
</LinearLayout>
</android.support.constraint.ConstraintLayout>

MAINACTIVITY.JAVA
package com.stn.exp2;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
public class MainActivity extends AppCompatActivity
{
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
public void google(View v)
{
Intent i = new Intent(MainActivity.this,google.class);
startActivity(i);
}

public void facebook(View v)


{
Intent i = new Intent(MainActivity.this,facebook.class);
startActivity(i);
}

public void twitter (View v)


{
Intent i = new Intent(MainActivity.this,twitter.class);
startActivity(i);
}
}

12
FACEBOOK.JAVA
package com.stn.exp2;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.webkit.WebView;

public class twitter extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_twitter);
WebView mywebview2=(WebView)findViewById(R.id.w3);
mywebview2.loadUrl("https://www.facebook.com");
}
}

GOOGLE.JAVA
package com.stn.exp2;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.webkit.WebView;

public class twitter extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_twitter);
WebView mywebview2=(WebView)findViewById(R.id.w3);
mywebview2.loadUrl("https://www.google.com");
}}

Output :

13
EVALUATION

Sl.No Module Max. Marks Marks Obtained


1 XML design 20
2 Java code 20
3 Execution in Android 10
4 Output 20
5 Technical Skill 20
6 Communication Skill 10
Total 100

Faculty Signature

RESULT:

Thus the Mobile browser based interactive application program is executed successfully in Android
studio.

14
Ex.No:3 Application using Controls (Simple Calculator)

Date:

Aim: To design the Application using Controls in Android studio.

ACTIVITYMAIN.XML
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Calculator"
android:textStyle="bold"
android:textColor="#000000"
android:textAllCaps="true"
android:textSize="25dp"
android:layout_marginLeft="60dp"
/>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#000000"
android:text="Enter the first number"
android:layout_marginTop="60dp"
android:textAllCaps="true"
android:textStyle="bold"
/>

<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="80dp"
android:id="@+id/firstnumber"
/>

<TextView

15
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#000000"
android:text="Enter the Second number"
android:layout_marginTop="150dp"
android:textAllCaps="true"
android:textStyle="bold"
/>

<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="190dp"
android:id="@+id/secondnumber"
/>
<Button
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_marginTop="250dp"
android:id="@+id/plus"
android:text="+"
android:textStyle="bold"
android:textSize="20dp"
android:onClick="addition"
/>

<Button
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_marginTop="250dp"
android:layout_marginLeft="70dp"
android:id="@+id/minus"
android:text="-"
android:textStyle="bold"
android:textSize="20dp"
android:onClick="subtraction"
/>

<Button
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_marginTop="250dp"
android:layout_marginLeft="140dp"
android:id="@+id/star"
android:text="*"
android:textStyle="bold"
android:textSize="20dp"
android:onClick="multiply"
/>

16
<Button
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_marginTop="250dp"
android:layout_marginLeft="210dp"
android:id="@+id/slash"
android:text="/"
android:textStyle="bold"
android:textSize="20dp"
android:onClick="divide"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Result is"
android:textColor="#000000"
android:textStyle="bold"
android:layout_marginTop="420dp"
android:textAllCaps="true"
/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="450dp"
android:id="@+id/result" />
</RelativeLayout>

MainActivity.java
package com.stn.exp3;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;

public class MainActivity extends AppCompatActivity


{

private EditText num1;


private EditText num2;
private EditText res;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
num1=findViewById(R.id.firstnumber);
num2=findViewById(R.id.secondnumber);

17
res=findViewById(R.id.result);

public void addition(View view)


{
int n1 = Integer.parseInt(num1.getText().toString());
int n2 = Integer.parseInt(num2.getText().toString());
int n3;
n3=n1+n2;
res.setText(Integer.toString(n3));

}
public void subtraction(View view)
{
int n1 = Integer.parseInt(num1.getText().toString());
int n2 = Integer.parseInt(num2.getText().toString());
int n3;
n3=n1-n2;
res.setText(Integer.toString(n3));

}
public void multiply(View view)
{
int n1 = Integer.parseInt(num1.getText().toString());
int n2 = Integer.parseInt(num2.getText().toString());
int n3;
n3=n1*n2;
res.setText(Integer.toString(n3));

}
public void divide(View view)
{
int n1 = Integer.parseInt(num1.getText().toString());
int n2 = Integer.parseInt(num2.getText().toString());
int n3;
n3=n1/n2;
res.setText(Integer.toString(n3)) }}}

18
OUTPUT

19
EVALUATION

Sl.No Module Max. Marks Marks Obtained


1 XML design 20
2 Java code 20
3 Execution in Android 10
4 Output 20
5 Technical Skill 20
6 Communication Skill 10
Total 100

Faculty Signature

RESULT:

Thus the applications using controls program is executed successfully in Android studio.

20
Ex.No:4 Sending SMS to Android

Date:

Aim: To design the Sending SMS to Android in Android studio.

Coding

• Include Internet permission, to access the internet feature of the mobile. Add this permission
above the <application >tag.

<uses-permission android:name="android.permission.SEND_SMS"/>
ANDROIDMANIFEST.XML

<?xml version="1.0" encoding="utf-8"?>


<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.stn.exp2">
<uses-permission android:name="android.permission.SEND_SMS"/>
<application
//PREDEFINED CODE
</application>

ACTIVITYMAIN.XML
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="SMS SENDER"
android:textSize="30dp"
android:textStyle="bold"
android:textColor="#000000"
android:layout_marginLeft="100dp"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Contact number"
android:textColor="#000000"
android:textSize="25dp"
21
android:textStyle="bold"
android:layout_marginTop="100dp”
/>
<EditText
android:id="@+id/contactnumber"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="phone"
android:layout_marginTop="130dp"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Enter the message"
android:textColor="#000000"
android:textSize="25dp"
android:textStyle="bold"
android:layout_marginTop="200dp"
/>
<EditText
android:id="@+id/message"
android:layout_width="match_parent"
android:layout_height="70dp"
android:layout_marginTop="250dp"
/>
<Button
android:layout_width="150dp"
android:layout_height="50dp"
android:layout_marginTop="350dp"
android:layout_marginLeft="100dp"
android:text="SEND"
android:textColor="#000000"
android:textStyle="bold"
android:textSize="20dp"
android:id="@+id/sendbtn"
android:onClick="sendmsg"
/>
</RelativeLayout>

ACTIVTYMAIN.JAVA
package com.stn.exp4;

import android.Manifest;
import android.content.pm.PackageManager;
import android.support.v4.app.ActivityCompat;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.telephony.SmsManager;

22
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

public class MainActivity extends AppCompatActivity {


final int SEND_SMS_PERMISSION_REQUEST_CODE=1;
private EditText CN;
private EditText Msg;
private Button send;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
CN=(EditText)findViewById(R.id.contactnumber);
Msg=(EditText)findViewById(R.id.message);
send=(Button)findViewById(R.id.sendbtn);
send.setEnabled(false); //disable the button
if(checkpermission(Manifest.permission.SEND_SMS))
{
send.setEnabled(true);
}
else
{
ActivityCompat.requestPermissions(this,new
String[]{Manifest.permission.SEND_SMS},SEND_SMS_PERMISSION_REQUEST_CODE);
}
}
public void sendmsg(View view)
{ String scn = CN.getText().toString();
String smsg = Msg.getText().toString();
if(scn.length()==0 || smsg.length()==0)
{
Toast.makeText(this,"Fill all columns",Toast.LENGTH_LONG).show();
return;
}
if(checkpermission(Manifest.permission.SEND_SMS)) {
SmsManager smsManager = SmsManager.getDefault();
smsManager.sendTextMessage(scn, null, smsg, null, null);
Toast.makeText(this, "Message sent Successfully", Toast.LENGTH_LONG).show();
}else
{
Toast.makeText(this, "Error in sending message ", Toast.LENGTH_LONG).show();
}
}
public boolean checkpermission(String permission)
{
int check = ContextCompat.checkSelfPermission(this,permission);
return (check == PackageManager.PERMISSION_GRANTED);

23
}
}

OUTPUT

24
EVALUATION

Sl.No Module Max. Marks Marks Obtained


1 XML design 20
2 Java code 20
3 Execution in Android 10
4 Output 20
5 Technical Skill 20
6 Communication Skill 10
Total 100

Faculty Signature

RESULT:

Thus the applications using controls program is executed successfully in Android studi

25
Ex.No:5 Application using Data retrieval

Date:

Aim: To design the Application using Data retrieval to Android in Android studio.

Steps to be followed to connect app to the firebase

Step 1: Create a Firebase project

Step 2: Register your app with Firebase.After you have a Firebase project, you can add your Android

app to it.In the center of the Firebase console's project overview page, click the Android icon to

launch the setup workflow.

Step 3: Enter your app's package name in the Android package name field.Make sure that you

Packagename that your app is actually using.Find this package name in manifest.Click Register app.

Step 4: Click Download google-services.json to obtain your Firebase Android config file (google-

services.json).Paste the google-services.json file in Project-->app folder.

Step5: Add the following dependencies to the android project in bulid.gradle(Module:app) folder.

implementation 'com.google.firebase:firebase-database:17.0.0'

dependencies {//predefined code

implementation 'com.google.firebase:firebase-database:17.0.0'

//predefined code}

26
ActivityMain.xml

<?xml version="1.0" encoding="utf-8"?>


<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="28dp"
android:text="STUDENT FORM"
android:textColor="#000000"
android:layout_marginLeft="80dp"
android:layout_marginTop="70dp"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Name"
android:textColor="#000000"
android:textSize="25dp"
android:layout_marginTop="150dp"

/>

<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="200dp"
android:id="@+id/name"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Department"
android:textColor="#000000"
android:textSize="25dp"
android:layout_marginTop="250dp"

/>

<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"

27
android:layout_marginTop="300dp"
android:id="@+id/department"
/>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="RegisterNumber"
android:textColor="#000000"
android:textSize="25dp"
android:layout_marginTop="350dp"

/>

<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="400dp"
android:id="@+id/regno"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="CGPA"
android:textColor="#000000"
android:textSize="25dp"
android:layout_marginTop="450dp"

/>

<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="500dp"
android:id="@+id/cgpa"
/>

<Button
android:layout_width="110dp"
android:layout_height="50dp"
android:layout_marginTop="600dp"
android:text="Submit"
android:layout_marginLeft="150dp"
android:onClick="submit"
/>

</RelativeLayout>

28
MainActivity.java
package com.stn.exp5;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.EditText;
import android.widget.Toast;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;
import com.stn.exp5.R;

public class MainActivity extends AppCompatActivity {

EditText Studentname;
EditText Studentdep;
EditText Studentregno;
EditText Studentcgpa;

DatabaseReference databaseReference;

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

databaseReference = FirebaseDatabase.getInstance().getReference("student");
Studentname = (EditText)findViewById(R.id.name);
Studentdep = (EditText)findViewById(R.id.department);
Studentregno = (EditText)findViewById(R.id.regno);
Studentcgpa=(EditText)findViewById(R.id.cgpa);

public void submit(View view)


{
String sname = Studentname.getText().toString();
String sdep = Studentdep.getText().toString();
String sregno = Studentregno.getText().toString();
String scgpa =Studentcgpa.getText().toString();

if(!TextUtils.isEmpty(sname)) {
Student student = new Student(sname, sdep, sregno, scgpa);
databaseReference.setValue(student);
Toast.makeText(getApplicationContext(),"Successfull",Toast.LENGTH_LONG).show();
}
else
{
Toast.makeText(getApplicationContext(),"UnSuccessfull",Toast.LENGTH_LONG).show();

29
} }
}

Student.java
package com.stn.exp5;

public class Student


{
String name;
String departmnet;
String regno;
String cgpa;

public Student() {
}

public Student(String name, String departmnet, String regno, String cgpa) {


this.name = name;
this.departmnet = departmnet;
this.regno = regno;
this.cgpa = cgpa;
}

public String getName() {


return name;
}

public String getDepartmnet() {


return departmnet;
}

public String getRegno() {


return regno;
}
public String getCgpa()
{
return cgpa; }
}

30
OUTPUT

BEFORE ADDING DATA

31
AFTER ADDING DATA

32
EVALUATION

Sl.No Module Max. Marks Marks Obtained


1 XML design 20
2 Java code 20
3 Execution in Android 10
4 Output 20
5 Technical Skill 20
6 Communication Skill 10
Total 100

Faculty Signature

RESULT:
Thus the applications using data retrieval program is executed successfully in Android studio.

33
Ex.No:6 Launching service in a mobile phone

Date:

Aim: To implement the current location of GPS in Android studio.

AndroidManifest.xml

• Include Location permission, to access the Location feature of the mobile. Add this
permission above the <application >tag.

<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>

<?xml version="1.0" encoding="utf-8"?>


<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.stn.exp6">

<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>

<application>
//predefined code
</application>
</manifest>

build.gradle(Module:app)

• To include Play services feature ,we have to include the following dependency

implementation 'com.google.android.gms:play-services:11.0.1'

dependencies {
//predefined code
implementation 'com.google.android.gms:play-services:11.0.1'
}

activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="GETTING LOCATION SERVICES"
34
android:textStyle="bold"
android:textColor="#000000"
android:layout_marginTop="30dp"
android:layout_marginLeft="50dp"
android:textSize="20dp"

/>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="200dp"
android:layout_marginLeft="70dp"
android:textSize="15dp"
android:textStyle="bold"
android:id="@+id/location"
/>
<Button
android:layout_width="150dp"
android:layout_height="75dp"
android:text="Get location"
android:layout_marginTop="290dp"
android:layout_marginLeft="110dp"
android:onClick="getlocation"
/>

</RelativeLayout>
MainActivity.java
package com.stn.exp6;

import android.Manifest;
import android.content.pm.PackageManager;
import android.location.Location;
import android.support.v4.app.ActivityCompat;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

import com.google.android.gms.location.FusedLocationProviderClient;
import com.google.android.gms.location.LocationServices;
import com.google.android.gms.tasks.OnSuccessListener;

import static android.Manifest.permission.ACCESS_FINE_LOCATION;

public class MainActivity extends AppCompatActivity {


private FusedLocationProviderClient client;
private TextView Location;

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

client = LocationServices.getFusedLocationProviderClient(this);
requestPermission();

}
public void getlocation(View view) {
if (ActivityCompat.checkSelfPermission(MainActivity.this, ACCESS_FINE_LOCATION) !=
PackageManager.PERMISSION_GRANTED ) {

return;
}
client.getLastLocation().addOnSuccessListener(MainActivity.this, new
OnSuccessListener<Location>() {
@Override
public void onSuccess(Location location) {
if(location!=null)
{
Location=(TextView)findViewById(R.id.location);
Location.setText(location.toString());
}

}
});
}

private void requestPermission()


{
ActivityCompat.requestPermissions(this,new String[]{ACCESS_FINE_LOCATION},1);
}

36
OUTPUT

37
EVALUATION

Sl.No Module Max. Marks Marks Obtained


1 XML design 20
2 Java code 20
3 Execution in Android 10
4 Output 20
5 Technical Skill 20
6 Communication Skill 10
Total 100

Faculty Signature

RESULT:

Thus the Location of the GPS is executed successfully in Android studio.

38
Ex.No:7 Web port development

Date:

Aim: To design the web port development in Android studio.

Steps to be followed to connect app to the firebase

Step 1: Create a Firebase project

Step 2: Register your app with Firebase.After you have a Firebase project, you can add your Android

app to it.In the center of the Firebase console's project overview page, click the Android icon to

launch the setup workflow.

Step 3: Enter your app's package name in the Android package name field.Make sure that you

Packagename that your app is actually using.Find this package name in manifest.Click Register app.

Step 4: Click Download google-services.json to obtain your Firebase Android config file (google-

services.json).Paste the google-services.json file in Project-->app folder.

Step5: Add the following dependencies to the android project in bulid.gradle(Module:app) folder.

implementation 'com.google.firebase:firebase-database:17.0.0'

dependencies {//predefined code

implementation 'com.google.firebase:firebase-database:17.0.0'

//predefined code}

39
ACTIVITY MAIN.XML:

<?xml version="1.0" encoding="utf-8"?>


<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Web Portal"
android:textColor="#000000"
android:textSize="40dp"
android:textStyle="bold|italic"
android:layout_marginTop="220dp"
android:layout_marginLeft="80dp"

/>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="1 Makeup Registration"
android:textSize="30dp"
android:textColor="#000000"
android:layout_marginLeft="40dp"
android:layout_marginTop="300dp"
android:onClick="makeup"
/>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="2 Arrear Registration"
android:textSize="30dp"
android:textColor="#000000"
android:layout_marginLeft="40dp"
android:layout_marginTop="360dp"
android:onClick="arrear"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="3 Course Registration"

40
android:textSize="30dp"
android:textColor="#000000"
android:layout_marginLeft="40dp"
android:layout_marginTop="420dp"
android:onClick="course"
/>
</RelativeLayout>

ACTIVITY_MAKEUP.XML

<?xml version="1.0" encoding="utf-8"?>


<ScrollView 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=".Makeup">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="27dp"
android:text="Makeup Registration"
android:textColor="#000000"
android:layout_marginLeft="50dp"
android:layout_marginTop="40dp"
/>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Name"
android:textColor="#000000"
android:textSize="25dp"
android:layout_marginTop="120dp"

/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="160dp"
android:id="@+id/mkname"
/>

<TextView

41
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Department"
android:textColor="#000000"
android:textSize="25dp"
android:layout_marginTop="220dp"
/>

<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="270dp"
android:id="@+id/mkdepartment"
/>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="RegisterNumber"
android:textColor="#000000"
android:textSize="25dp"
android:layout_marginTop="320dp"

/>

<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="370dp"
android:id="@+id/mkregno"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="No.of.Makeup"
android:textColor="#000000"
android:textSize="25dp"
android:layout_marginTop="420dp"

/>

<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="470dp"
android:id="@+id/mkcount"
/>

42
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="List of Makeup"
android:textColor="#000000"
android:textSize="25dp"
android:layout_marginTop="520dp"

/>

<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="570dp"
android:id="@+id/mklist"
/>

<Button
android:layout_width="150dp"
android:layout_height="75dp"
android:text="Register"
android:layout_marginTop="640dp"
android:layout_marginLeft="120dp"
android:onClick="mkregister"
/>

</RelativeLayout>

</ScrollView>

ACTIVITY_ARREAR.XML

<?xml version="1.0" encoding="utf-8"?>


<ScrollView 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=".Arrear">

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">

<TextView
android:layout_width="wrap_content"

43
android:layout_height="wrap_content"
android:textSize="27dp"
android:text="Arrear registration"
android:textColor="#000000"
android:layout_marginLeft="50dp"
android:layout_marginTop="40dp"
/>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Name"
android:textColor="#000000"
android:textSize="25dp"
android:layout_marginTop="120dp"

/>

<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="160dp"
android:id="@+id/arrname"
/>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Department"
android:textColor="#000000"
android:textSize="25dp"
android:layout_marginTop="220dp"

/>

<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="270dp"
android:id="@+id/arrdepartment"
/>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="RegisterNumber"

44
android:textColor="#000000"
android:textSize="25dp"
android:layout_marginTop="320dp"

/>

<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="370dp"
android:id="@+id/arrregno"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="No.of.Arrears"
android:textColor="#000000"
android:textSize="25dp"
android:layout_marginTop="420dp" />

<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="470dp"
android:id="@+id/arrearcount"
/>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="List of Arrears"
android:textColor="#000000"
android:textSize="25dp"
android:layout_marginTop="520dp"

/>

<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="570dp"
android:id="@+id/arrearlist"
/>
<Button
android:layout_width="150dp"
android:layout_height="75dp"
android:text="Register"
android:layout_marginTop="640dp"
android:layout_marginLeft="120dp"
android:onClick="arrearregister"

45
/>

</RelativeLayout>

</ScrollView>

ACTIVITY_COURSE.XML

<?xml version="1.0" encoding="utf-8"?>


<ScrollView 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=".Course">

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="27dp"
android:text="Course registration"
android:textColor="#000000"
android:layout_marginLeft="50dp"
android:layout_marginTop="40dp"
/>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Name"
android:textColor="#000000"
android:textSize="25dp"
android:layout_marginTop="120dp"

/>

<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="160dp"
android:id="@+id/crname"
/>

46
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Department"
android:textColor="#000000"
android:textSize="25dp"
android:layout_marginTop="220dp"

/>

<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="270dp"
android:id="@+id/crdepartment"
/>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="RegisterNumber"
android:textColor="#000000"
android:textSize="25dp"
android:layout_marginTop="320dp"

/>

<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="370dp"
android:id="@+id/crregno"
/>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Subjects/semester"
android:textColor="#000000"
android:textSize="25dp"
android:layout_marginTop="420dp"

/>

47
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="470dp"
android:id="@+id/crcount"
/>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="List of Subjects"
android:textColor="#000000"
android:textSize="25dp"
android:layout_marginTop="520dp"

/>

<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="570dp"
android:id="@+id/crlist"
/>

<Button
android:layout_width="150dp"
android:layout_height="75dp"
android:text="Register"
android:layout_marginTop="640dp"
android:layout_marginLeft="120dp"
android:onClick="courseregister"
/>

</RelativeLayout>

</ScrollView>

MAINACTIVITY.JAVA

package com.stn.exp7;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;

public class MainActivity extends AppCompatActivity {

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

public void makeup(View view)


{
Intent i = new Intent(MainActivity.this,Makeup.class);
startActivity(i);
}

public void arrear(View view)


{

Intent i = new Intent(MainActivity.this,Arrear.class);


startActivity(i);

public void course(View view)


{
Intent i = new Intent(MainActivity.this,Course.class);
startActivity(i);
}
}

GETTER.JAVA

package com.stn.exp7;

public class Getter


{
String name;
String dep;
String count;
String list;

public Getter() {
}

public Getter(String name, String dep, String count, String list) {


this.name = name;
this.dep = dep;
this.count = count;
this.list = list;
}

49
public String getName() {
return name;
}

public String getDep() {


return dep;
}

public String getCount() {


return count;
}

public String getList() {


return list;
}
}

MAKEUP.JAVA

package com.stn.exp7;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.EditText;
import android.widget.Toast;

import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;

public class Makeup extends AppCompatActivity {


private EditText MKNAME;
private EditText MKDEP;
private EditText MKREG;
private EditText MKCOUNT;
private EditText MKLIST;
DatabaseReference reference;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_makeup);
MKNAME=(EditText)findViewById(R.id.mkname);
MKDEP=(EditText)findViewById(R.id.mkdepartment);
MKREG=(EditText)findViewById(R.id.mkregno);
MKCOUNT=(EditText)findViewById(R.id.mkcount);
MKLIST=(EditText)findViewById(R.id.mklist);
}

50
public void mkregister(View view)
{
String name=MKNAME.getText().toString();
String dep=MKDEP.getText().toString();
String reg=MKREG.getText().toString();
String count=MKCOUNT.getText().toString();
String list=MKLIST.getText().toString();
reference= FirebaseDatabase.getInstance().getReference("Makeup Registration").child(name);

if(!TextUtils.isEmpty(name))
{
Getter gt =new Getter(name,dep,count,list);
reference.setValue(gt);
Toast.makeText(getApplicationContext(),"Registration
Successful",Toast.LENGTH_LONG).show();
}
else
{
Toast.makeText(getApplicationContext(),"Registration
Failed",Toast.LENGTH_LONG).show();

}
}

ARREAR.JAVA
package com.stn.exp7;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.EditText;
import android.widget.Toast;

import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;

public class Arrear extends AppCompatActivity {


private EditText ARRNAME;
private EditText ARRDEP;
private EditText ARRREG;
private EditText ARRCOUNT;
private EditText ARRLIST;
DatabaseReference reference; //an object is used to refer the firebase realtime database
51
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_arrear);

ARRNAME=(EditText)findViewById(R.id.arrname);
ARRDEP = (EditText)findViewById(R.id.arrdepartment);
ARRREG = (EditText)findViewById(R.id.arrregno);
ARRCOUNT = (EditText)findViewById(R.id.arrearcount);
ARRLIST = (EditText)findViewById(R.id.arrearlist);
}

public void arrearregister(View view)


{
String name=ARRNAME.getText().toString();
String dep= ARRDEP.getText().toString();
String reg = ARRREG.getText().toString();
String count=ARRCOUNT.getText().toString();
String list = ARRLIST.getText().toString();
reference = FirebaseDatabase.getInstance().getReference("Arrear Registration").child(name);

if(!TextUtils.isEmpty(name))
{
Getter gt = new Getter(name,dep,count,list);
reference.setValue(gt);

Toast.makeText(getApplicationContext(),"ArrearRegistrationSuccessful",Toast.LENGTH_LONG)
.show();
}
else
{
Toast.makeText(getApplicationContext(),"FAILED",Toast.LENGTH_LONG).show();
}

}
}
COURSE.JAVA

package com.stn.exp7;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;

52
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;

public class Course extends AppCompatActivity {

private EditText CRNAME;


private EditText CRDEP;
private EditText CRREG;
private EditText CRCOUNT;
private EditText CRLIST;
DatabaseReference reference;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_course);

CRNAME = (EditText)findViewById(R.id.crname);
CRDEP=(EditText)findViewById(R.id.crdepartment);
CRREG=(EditText)findViewById(R.id.crregno);
CRCOUNT =(EditText)findViewById(R.id.crcount);
CRLIST =(EditText)findViewById(R.id.crlist);

public void courseregister(View view)


{
String name= CRNAME.getText().toString();
String dep=CRDEP.getText().toString();
String reg=CRREG.getText().toString();
String count=CRCOUNT.getText().toString();
String list=CRLIST.getText().toString();
reference = FirebaseDatabase.getInstance().getReference("Course Registration").child(name);

if(!TextUtils.isEmpty(name)) {
Getter gt = new Getter(name, dep, count, list);
reference.setValue(gt);
Toast.makeText(getApplicationContext(),"Registration
successfull",Toast.LENGTH_LONG).show();
}
else
{
Toast.makeText(getApplicationContext(),"Registration
Failed",Toast.LENGTH_LONG).show();

}
}
}

53
OUTPUT

54
EVALUATION

Sl.No Module Max. Marks Marks Obtained


1 XML design 20
2 Java code 20
3 Execution in Android 10
4 Output 20
5 Technical Skill 20
6 Communication Skill 10
Total 100

Faculty Signature

RESULT:

Thus the web port development program is executed successfully in Android studio.

55
Ex.No:8 video application

Date:

Aim: To design the video application in Android studio.

Building the layout

Now that we’ve created the app and its initial files let’s make a few changes to the layout to
accommodate our video conversations.

Open TwilioVideo/app/src/main/res/layout/activity_main.xml and change the icon and background


colour of your floating action button as follows:

<android.support.design.widget.FloatingActionButton

android:id="@+id/call_action_fab"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_gravity="bottom|end"

android:layout_margin="@dimen/fab_margin"

android:src="@android:drawable/ic_menu_call"

app:backgroundTint="@android:color/holo_green_dark"/>

In TwilioVideo/app/src/main/res/layout/content_main.xml delete the existing TextView, create


a FrameLayout and add a couple of Relative Layouts inside. These will be our containers where we
will later see a video of ourselves and one of our friends.

<RelativeLayout
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="com.twilio.twiliovideo.MainActivity"
tools:showIn="@layout/activity_main">

56
<FrameLayout
android:id="@+id/previewFrameLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
<LinearLayout
android:id="@+id/videoLinearLayout"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:id="@+id/localContainer"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"/>
<RelativeLayout
android:id="@+id/participantContainer"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"/>

</LinearLayout>

</RelativeLayout>

Permissions & Dependencies


Now that our application has a layout we can download and reference the necessary dependencies.
We will also ask for the required permissions to access the device’s hardware.

In order to get access to the device’s camera, we need to install and initialise the Twilio SDK. To
install it, change TwilioVideo/app/build.gradle to have the following added to it:

repositories{

57
// Twilio Maven repository - currently required for TwilioCommon

maven{

url"http://media.twiliocdn.com/sdk/maven/"

dependencies{

compilefileTree(dir:'libs',include:['*.jar'])

testCompile'junit:junit:4.12'

compile'com.android.support:appcompat-v7:23.2.0'

compile'com.android.support:design:23.2.0'

compile'com.twilio:conversations-android:0.8.1'

compile'com.squareup.okhttp3:okhttp:3.1.2'

At this point Android Studio will tell you that “Gradle files have changed since last project sync”.
Click Sync Now, and all the dependencies will be downloaded and properly referenced.

Open TwilioVideo/app/src/main/AndroidManifest.xml and add permissions for camera, audio and


internet access.

<uses-featureandroid:name="android.hardware.camera"/>

<uses-featureandroid:name="android.hardware.camera.autofocus"/>

<uses-permissionandroid:name="android.permission.CAMERA"/>

<uses-permissionandroid:name="android.permission.INTERNET"/>

<uses-permissionandroid:name="android.permission.RECORD_AUDIO"/>

<uses-permissionandroid:name="android.permission.MODIFY_AUDIO_SETTINGS"/>

<uses-permissionandroid:name="android.permission.ACCESS_NETWORK_STATE"/>

<uses-permissionandroid:name="android.permission.ACCESS_WIFI_STATE"/>

<application

58
android:allowBackup="true"

android:icon="@mipmap/ic_launcher"Open TwilioVideo/app/src/main/java/com/twilio/twiliovideo/
MainActivity.java and create a condition to check that the permissions have indeed been given. We
can do that by creating a couple of new methods inside the class to check and then request when the
permissions have not been granted.

We can also remove some of the unnecessary methods in this class so it looks like the following
code.

publicclassMainActivityextendsAppCompatActivity{

@Override

protectedvoidonCreate(BundlesavedInstanceState){

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_main);

privatebooleancheckPermissionForCameraAndMicrophone(){

intresultCamera=ContextCompat.checkSelfPermission(this,Manifest.permission.CAMERA);

intresultMic=ContextCompat.checkSelfPermission(this,Manifest.permission.RECORD_AUDIO);

return(resultCamera==PackageManager.PERMISSION_GRANTED)&&(resultMic==PackageMana
ger.PERMISSION_GRANTED);

privatevoidrequestPermissionForCameraAndMicrophone(){

if(ActivityCompat.shouldShowRequestPermissionRationale(this,Manifest.permission.CAMERA)||A
ctivityCompat.shouldShowRequestPermissionRationale(this,Manifest.permission.RECORD_AUDIO
)){

Toast.makeText(this,"Camera and Microphone permissions needed. Please allow in App Settings for
additional functionality.",Toast.LENGTH_LONG).show();

}else{

ActivityCompat.requestPermissions(this,newString[]{Manifest.permission.CAMERA,Manifest.perm
ission.RECORD_AUDIO},1);

59
}We’re now going to add a few member variables to the class, and replace the whole
of onCreate with the following.

privateStringmAccessToken;

privatestaticfinalStringTAG=MainActivity.class.getName();

/*

* Android application UI elements

*/

privateFrameLayoutpreviewFrameLayout;

privateViewGrouplocalContainer;

privateViewGroupparticipantContainer;

privateFloatingActionButtoncallActionFab;

privateOkHttpClientclient=newOkHttpClient();

privateTwilioAccessManageraccessManager;

privateConversationsClientconversationsClient;

privateCameraCapturercameraCapturer;

privateConversationconversation;

privateOutgoingInviteoutgoingInvite;

privateContextmContext;

/*

* A VideoViewRenderer receives frames from a local or remote video track and renders the frames
to a provided view

*/

privateVideoViewRendererparticipantVideoRenderer;

privateVideoViewRendererlocalVideoRenderer;

@Override

protectedvoidonCreate(BundlesavedInstanceState){

60
super.onCreate(savedInstanceState);

setContentView(R.layout.activity_main);

mContext=this.getApplicationContext();

/*

* Check camera and microphone permissions. Needed in Android M.

*/

if(!checkPermissionForCameraAndMicrophone()){

requestPermissionForCameraAndMicrophone();

/*

* Load views from resources

*/

previewFrameLayout=(FrameLayout)findViewById(R.id.previewFrameLayout);

localContainer=(ViewGroup)findViewById(R.id.localContainer);

participantContainer=(ViewGroup)findViewById(R.id.participantContainer);

getCapabilityToken();

}This will make use of our new permission methods to check whether access to the camera and
microphone have been granted, then create references to our layout widgets which we will use later
on. Lastly, it will make a call to the method getCapabilityToken which we’re just about to create.

Initialising the Twilio SDK


Make sure the quickstart application you downloaded earlier is still running, and that you have its
ngrok URL. We will initialise the Twilio SDK by giving it a Capability Token that is returned by the
quickstart.

Very soon you will be wondering which are the correct imports to use because you will have a lot of
red squiggles under your code. To make things easier, just copy all the imports from this file and
replace what you currently have.

In MainActivity.java create a new method called getCapabilityToken inside the class. This will make
use of our ngrok URL.

61
privatevoidgetCapabilityToken(){

try{

run("http://[your-ngrok-url].ngrok.io/token",newCallback(){

@Override

publicvoidonFailure(Callcall,IOExceptione){

e.printStackTrace();

@Override

publicvoidonResponse(Callcall,Responseresponse)throwsIOException{

try{

Stringtoken=response.body().string();

JSONObjectobj=newJSONObject(token);

mAccessToken=obj.getString("token");

Log.d(TAG,token);

initializeTwilioSdk(mAccessToken);

}catch(Exceptione){

e.printStackTrace();

});

}catch(IOExceptione){

e.printStackTrace();

privateCallrun(Stringurl,Callbackcallback)throwsIOException{

62
Requestrequest=newRequest.Builder()

.url(url)

.build();

Callresponse=client.newCall(request);

response.enqueue(callback);

returnresponse;

}Notice that we have also created a method called run, which uses OkHttp – one of our dependencies
– to make an HTTP request to our backend application. Make sure you replace the contents of [your-
ngrok-url] with the URL you got from ngrok.

The new method overrides OnResponse with a call to initializeTwilioSDK which we will create in a
minute. That method will only be called when we get a response from the server with a capability
token.

privatevoidinitializeTwilioSdk(finalStringaccessToken){

TwilioConversations.setLogLevel(TwilioConversations.LogLevel.DEBUG);

if(!TwilioConversations.isInitialized()){

TwilioConversations.initialize(this.mContext,newTwilioConversations.InitListener(){

@Override

63
publicvoidonInitialized(){

accessManager=TwilioAccessManagerFactory.createAccessManager(accessToken,accessManagerLi
stener());

conversationsClient=TwilioConversations.createConversationsClient(accessManager,conversationsC
lientListener());

// Specify the audio output to use for this conversation client

conversationsClient.setAudioOutput(AudioOutput.SPEAKERPHONE);

// Initialize the camera capturer and start the camera preview

cameraCapturer=CameraCapturerFactory.createCameraCapturer(MainActivity.this,CameraCapturer.
CameraSource.CAMERA_SOURCE_FRONT_CAMERA,previewFrameLayout,capturerErrorListen
er());

startPreview();

// Register to receive incoming invites

conversationsClient.listen();

@Override

publicvoidonError(Exceptione){

Toast.makeText(MainActivity.this,

"Failed to initialize the Twilio Conversations SDK",

Toast.LENGTH_LONG).show();

});

}There are four important things to notice on the code above. We first get access to
the TwilioAccessManager interface which will authenticate the application using the capability token
we got earlier and listen to any expirations or errors on that. Once we have that, we pass this
information to a listener.

We then create a new conversations client which takes an event listener


called conversationsClientListener and listens to things like new invites to the conversation.

64
Once the conversation is established we get access to the camera and when that’s granted, we start
previewing it to the screen.

Let’s add these event listeners to the bottom of the class and a method to start and stop previewing
the camera on the screen. We will bind the camera to the previewFrameLayout we created earlier.

privateTwilioAccessManagerListeneraccessManagerListener(){

returnnewTwilioAccessManagerListener(){

@Override

publicvoidonAccessManagerTokenExpire(TwilioAccessManagertwilioAccessManager){

@Override

publicvoidonTokenUpdated(TwilioAccessManagertwilioAccessManager){

@Override

publicvoidonError(TwilioAccessManagertwilioAccessManager,Strings){

};

privateConversationsClientListenerconversationsClientListener(){

returnnewConversationsClientListener(){

@Override

publicvoidonStartListeningForInvites(ConversationsClientconversationsClient){

@Override

publicvoidonStopListeningForInvites(ConversationsClientconversationsClient){

@Override

65
publicvoidonFailedToStartListening(ConversationsClientconversationsClient,TwilioConversationsE
xceptione){

@Override

publicvoidonIncomingInvite(ConversationsClientconversationsClient,IncomingInviteincomingInvite
){

@Override

publicvoidonIncomingInviteCancelled(ConversationsClientconversationsClient,IncomingInviteinco
mingInvite){

};

privateCapturerErrorListenercapturerErrorListener(){

returnnewCapturerErrorListener(){

@Override

publicvoidonError(CapturerExceptione){

Log.e(TAG,"Camera capturer error:"e.getMessage());

};

privatevoidstartPreview(){

cameraCapturer.startPreview();

privatevoidstopPreview(){

if(cameraCapturer!=null&&cameraCapturer.isPreviewing()){

cameraCapturer.stopPreview();

66
}

OUTPUT

EVALUATION

Sl.No Module Max. Marks Marks Obtained


1 XML design 20
2 Java code 20
3 Execution in Android 10
4 Output 20
5 Technical Skill 20
6 Communication Skill 10
Total 100

Faculty Signature

RESULT:

Thus the video application program is executed successfully in Android studio.

67
Ex.No:9 Name: Application using iphone SDK framework

Date:

Aim: To study for application in iphone SDK framework.

Procedure:

Framework Set Up
In Xcode 6, Apple introduced the Cocoa Touch Framework template along with access control, so
creating frameworks has never been easier. The first thing to do is to create the project for the
framework.

In Xcode, select File -> New -> Project.

Choose iOS -> Framework & Library -> Cocoa Touch Framework.

Click Next.

Set the Product Name to KnobControl. Use your own Organization Name and Organization
Identifier.

68
Click Next.

In the file chooser, choose to create the project at the same level as the KnobShowcase root
folder.

Click Create.

Now you have a project (albeit a boring one) that creates a framework!

Add Code
Your current state is a framework without code, and that is about as appealing as straight chocolate
without sugar. In this section, you’ll introduce code by adding the existing files to the framework.

69
From the KnobShowcase source directory, drag the Knob.swift file into the KnobControl project in
Xcode. Make sure to check Copy items if needed so that the files actually copy into the new project
instead of just adding a reference. Frameworks need their own code, not references, to be
independent.

Double-check that Knob.swift has Target Membership in KnobControl to make sure it appears in the
final framework. You can verify this in the File inspector.

70
Build the framework project to make sure that you get Build Succeeded with no build warnings or
errors. If you read the How to Make a Custom Control tutorial, you may recall Knob.swift contains
three different classes:

• Knob: the actual custom control.


• KnobRenderer: a private class that keeps track of the code associated with rendering the knob
itself.
• RotationGestureRecognizer: a private class that enables the interaction with the knob.

Your next task is to separate those components into different files. Start by moving KnobRenderer:

1. Go to File -> New -> File… and select iOS -> Source -> Swift File.
2. Click Next.
3. On the next screen, specify the class name as KnobRenderer and choose the KnobControl ->
KnobControl directory.
4. Click Create.
5. Open Knob.swift, cut (Command-X) the entire KnobRenderer class and paste it (Command-
V) into KnobRenderer.swift just below the import Foundation statement.
6. Remove the private modifier for KnobRenderer. When the code was all contained
in Knob.swift this was fine, but now it must be accessible throughout the module with the
default internal modifier.

Repeat steps 1 to 6 for the RotationGestureRecognizer class. In this case, when you perform the fifth
step, make sure you also grab the import UIKit.UIGestureRecognizerSubclass statement, otherwise
the compiler will complain during the build phase.

With your two new files created, Knob.swift now only contains the Knob class.

71
Note: Separating classes into their own files is not strictly necessary, but it’s a good practice in order
to make your code organized. You don’t want to have a huge file that is hard to comprehend and
maintain.

Add the Framework to the Project


Close the KnobControl project, and go back to the KnobShowcase project. Delete Knob.swift file.
Select Move to Trash in the confirmation dialog.

Build the project, and you’ll see several predictable errors where Xcode complains about not
knowing what the heck a Knob is. Well, you’ll actually see Use of undeclared type ‘Knob’ error
message.

Adding the KnobControl framework project is the solution to these problems.Embed Your Binary
Right-click on the root KnobShowcase node in the project navigator. Click Add Files to
“KnobShowcase”. In the file chooser, navigate to and select KnobControl.xcodeproj. Click Add to
add KnobControl.xcodeproj as a sub-project.

72
Note: It isn’t strictly necessary to add the framework project to the app project; you could just add
the KnobControl.framework output.

However, combining the projects makes it easier to develop both the framework and app
simultaneously. Any changes you make to the framework project are automatically propagated up to
the app. It also makes it easier for Xcode to resolve the paths and know when to rebuild the project.

Build and run, and you’ll see that same compile error!

Even though the two projects are now together, KnobShowcase still doesn’t get KnobControl. It’s
like they’re sitting in the same room, but KnobShowcase can’t see the new framework.

You’ll link the framework to the app’s target to fix this problem. First, expand
the KnobControl project to see the Products folder, and then look
for KnobControl.framework beneath it. This file is the output of the framework project that packages
up the binary code, headers, resources and metadata.

73
Select the top level KnobShowcase node to open the project editor. Click the KnobShowcase target,
and then go to the General tab.

Scroll down to the Embedded Binaries section. Drag KnobControl.framework from


the Products folder of KnobControl.xcodeproj onto this section.

You just added an entry for the framework in both Embedded Binaries and Linked Frameworks and
Binaries.

RESULT: Thus the iphone SDK framework application is studied.

74
Ex.No:10 Testing the application using emulator

Date:

Aim: To study for testing the application using emulator in iOS environment.

Procedure:

Mobile web testing can be challenging because of a variety of mobile devices, platforms and screen sizes.
Test Complete addresses this challenge by letting you test mobile web applications using an emulator
with preconfigured phone and tablet browser profiles. You do not need real devices for testing, which
simplifies your testing setup and maintenance.

About Mobile Web Testing With Test Complete:

Web developers use various techniques to make mobile web applications compatible with different
mobile devices and screen sizes. For example:

• Responsive web design lets web sites adapt the page layout to various screen sizes.

• Platform detection lets web sites show device-specific content.

Testing helps verify that your mobile web site application looks and works fine on various devices.

Using Test Complete, you can record automated tests in the mobile browser emulator and play them back
using different browser profiles. This way you can –

• Create and run functional tests for a web application’s business logic.

• Check how a web site looks on different screen sizes.

• Verify that a web site with mobile device detection returns the correct content to different
devices.

Mobile web testing with Test Complete is similar to testing regular (non-mobile) web sites, with a few
exceptions described. For example, Test Complete uses the same test objects, methods and properties for
both mobile and non-mobile browsers, web pages and web page elements. If necessary, see the following
topics first to get a general understanding of how to perform web testing with Test Complete:

How Test Complete Emulates Mobile Browsers


Test Complete uses Google Chrome to emulate mobile browsers. The emulation mode changes some
browser characteristics to match those of mobile devices:

• User agent – The string that identifies the browser to web servers. It includes the browser version,
operating system and its version, and other information. The user agent makes the web sites
“think” they are viewed on a mobile device. As a result, web sites return mobile content even
though you test on a desktop computer.

75
• Browser screen size and device pixel ratio (to emulate Retina displays).

• Emulation of touch events, meta viewport, and mobile scrollbar overlays.

Click the image to enlarge it.

Test Complete includes predefined mobile browser profiles for Apple iPhone, iPad, Google Nexus,
Samsung Galaxy, and other devices.

Creating and Recording Mobile Web Tests


The easiest way to create tests is to record them and then change the recorded tests as needed. You can
also create tests manually from scratch, if you wish.

Creating a mobile web test includes the following steps –

1. (Optional.) Add custom mobile devices you want to test your site with.

2. Record a test using the mobile browser emulator:

• Start test recording.

• Select a mobile browser profile from the Run App | Virtual Browser drop-down list on
the Recording toolbar. Test Complete will launch the emulator with the selected profile.

76
• Open your tested web site in the mobile browser emulator.

• Perform test actions (navigate through web pages, fill out forms and so on) and
create checkpoints for the tested web site.

• Stop test recording.

3. Modify the recorded test, if needed.

4. Run the test to make sure it passes. If needed, debug the test to find and fix the issues.

5. Configure the test so that it runs using all needed mobile browser profiles. For more information,
see Creating Cross-Browser Mobile Web Tests Using Emulator.

RESULT: Thus the testing for the application using emulator in iOS environment is studied.

77

Вам также может понравиться