Anna University: N PRITHVI (2016105610) A SAI KUMAR (2016105582)

Download as pdf or txt
Download as pdf or txt
You are on page 1of 12

ANNA UNIVERSITY

COLLEGE OF ENGINEERING GUINDY

EC7712 – WIRELESS COMMUNICATION


AND NETWORKING LABORATORY

REPORT - CHAT BOX

SUBMITTED BY

N PRITHVI (2016105610)
A SAI KUMAR(2016105582)

KP HARISH (2016105028)
S SRI HARIHARAN(2016105592)

1
TABLE OF CONTENTS

Sl.No NAME OF THE EXPERIMENT PAGE

1 INTRODUCTION 3

2 MOTIVATION 3

3 DESIGN STEPS 4

4 TOOLS AND SOFTWARE USED 6

5 CODE 7

6 RESULTS 13

7 CONCLUSION 14

2
INTRODUCTION:
Android is a mobile operating system based on a modified version of the Linux kernel
and other open source software, designed primarily for touchscreen mobile devices such
as smartphones and tablets. Android is developed by a consortium of developers known
as the Open Handset Alliance, with the main contributor and commercial marketer being
Google.

Applications ("apps"), which extend the functionality of devices, are written using the
Android software development kit (SDK) and, often, the Java programming language.
Java may be combined with C/C++,] together with a choice of non-default runtimes that
allow better C++ support. The Go programming language is also supported, although
with a limited set of application programming interfaces (API)

The SDK includes a comprehensive set of development tools, including a debugger,


software libraries, a handset emulator based on QEMU, documentation, sample code,
and tutorials.In December 2014, Google released Android Studio, based on IntelliJ
IDEA, as its primary IDE for Android application development

Android has a growing selection of third-party applications, which can be acquired by


users by downloading and installing the application's APK (Android application
package) file, or by downloading them using an application store program that allows
users to install, update, and remove applications from their devices. Google Play Store is
the primary application store installed on Android devices that comply with Google's
compatibility requirements and license the Google Mobile Services software. Google
Play Store allows users to browse, download and update applications published by
Google and third-party developers

CHAT BOX APP:


This application helps us to send messages from our mobile phones to another.
Messaging is the most primitive form of communication among others like voice calls, video
calls etc, yet it is the most preferred form of communication. It is not so active like the others.
We can send and reply whenever we want, or even ignore them. It is more convenient to
convey small information which doesn’t require calling the person. Its also cheaper than other
forms of communication.

MOTIVATION:

Every smart phone has an messaging app which is in built. But it is mostly a standard
template and lacks features. Chat box aims to address those issues by adding a dark
mode to prevent eye strain making the messaging experience more convenient and
stramlined.It has a dedicated switch to toggle between dark mode and normal mode
whenever the user wants.

3
DESIGN STEPS:

1. In the Welcome to Android Studio window, click Start a new Android


Studio project.

2. In the Choose your project window, select Empty Activity and


click Next.
3. In the Configure your project window, complete the following:
a. Enter "Chat box" in the Name field.
b. Enter "com.example.chatbox" in the Package name field.
c. If you'd like to place the project in a different folder, change
its Save location.
d. Select either Java from the Language drop-down menu.
e. Select the checkbox next to Use androidx.* artifacts.
f. Leave the other options as they are.
4. Click Finish.
After some processing time, the Android Studio main window appears.

4
5. Make Project window is open (select View > Tool Windows > Project)
and the Android view is selected from the drop-down list at the top of that
window. The following files are then modified:

app > java > com.example.mynotes > MainActivity


This is the main activity. It's the entry point for the app. When build and
run your app, the system launches an instance of this Activity and loads
its layout.

app > res > layout > activity_main.xml

This XML file defines the layout for the activity's user interface (UI). It
contains a TextView element with the text "Hello, World!"

app > manifests > AndroidManifest.xml

The manifest file describes the fundamental characteristics of the app and
defines each of its components.

Gradle Scripts > build.gradle


There are two files with this name: one for the project, "Project: My First
App," and one for the app module, "Module: app." Each module has its
own build.gradle file, but this project currently has just one module. Use
each module's build.file to control how the Gradle plugin builds your app.
For more information about this file, see Configure your build.

5
6. Connect your device to your development machine with a USB cable.
7. Enable USB debugging in the Developer options window.
8. In Android Studio, select your app from the run/debug configurations
drop-down menu in the toolbar.
9. In the toolbar, select the device that you want to run your app on from the
target device drop-down menu.

TOOLS AND SOFTWARE USED:


• Android studio
• Java
• Photoshop

6
CODE:

Mainactivity:(java)
package com.example.demoapp;

import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;

import android.Manifest;
import android.content.pm.PackageManager;
import android.graphics.Color;
import android.os.Bundle;
import android.telephony.SmsManager;
import android.view.View;
import android.widget.CompoundButton;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.Switch;
import android.widget.Toast;

public class MainActivity extends AppCompatActivity {

EditText txt_pNumber,txt_message;

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

txt_message=(EditText)findViewById(R.id.txt_message);
txt_pNumber=(EditText)findViewById(R.id.txt_phone_number);

public void btn_send(View view) {

int permissionCheck= ContextCompat.checkSelfPermission(this, Manifest.permission.SEND_SMS);


if (permissionCheck== PackageManager.PERMISSION_GRANTED){

MyMessage();

}
else{
ActivityCompat.requestPermissions(this,new String[]{Manifest.permission.SEND_SMS},0);

}
}
7
private void MyMessage() {

String phoneNumber = txt_pNumber.getText().toString().trim();


String Message= txt_message.getText().toString().trim();

if (!txt_pNumber.getText().toString().equals("")|| !txt_message.getText().toString().equals("")) {

SmsManager smsManager = SmsManager.getDefault();


smsManager.sendTextMessage(phoneNumber, null, Message, null, null);
Toast.makeText(this, "Message Sent", Toast.LENGTH_SHORT).show();

}
else {
Toast.makeText(this, "Enter Phone Number or Message", Toast.LENGTH_SHORT).show();
}

@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[]
grantResults) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults);

switch (requestCode){

case 0:

if(grantResults.length>= 0&& grantResults[0]==PackageManager.PERMISSION_GRANTED){


MyMessage();
}
else{
Toast.makeText(this, "You dont have required permission to make this action",
Toast.LENGTH_SHORT).show();
}
break;
}
}

public void darkmode(View view) {


Switch sw1;
sw1 = (Switch)findViewById(R.id.switch1);
sw1.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (isChecked) {
// The toggle is enabled
LinearLayout li = (LinearLayout)findViewById(R.id.ab);
li.setBackgroundColor(Color.BLACK);
}
else {
LinearLayout li = (LinearLayout)findViewById(R.id.ab);
li.setBackgroundColor(Color.WHITE);
}
8
});
}

Activityxml:(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"
android:padding="20dp"
android:id="@+id/ab"
tools:context=".MainActivity">

<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Enter Phone Number:"
android:layout_marginTop="10dp"
android:textSize="22sp"
android:inputType="phone"
android:id="@+id/txt_phone_number"

/>
<EditText
android:layout_width="match_parent"
android:layout_height="300dp"
android:layout_marginTop="10dp"
android:hint="Enter Message:"

android:gravity="top"
android:textSize="22sp"
android:id="@+id/txt_message"

/>
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Send"
android:textSize="25sp"
android:layout_marginTop="10dp"
android:onClick="btn_send"
/>
<Switch
android:id="@+id/switch1"
android:layout_width="370dp"
android:layout_height="148dp"
android:checked="true"
android:onClick="darkmode"

9
android:switchTextAppearance="@style/TextAppearance.AppCompat.Large"
android:text="dark mode"
android:textOff="OFF"
android:textOn="ON" />

</LinearLayout>

10
RESULTS:

Default mode:

11
Dark mode:

CONCLUSION:

Messaging is the primitive form of communication in the modern technological world.


From conveying important messages to interacting with people it is an efficient and
quick way to communicate with others. With this app it is more convenient as well as
personalized to make the user experience better.

12

You might also like