Professional Documents
Culture Documents
MCA Practical Solution
MCA Practical Solution
Development
Practical: 1
To study about mobile computing and its architecture.
Presentation Tier (Tier-1)
• This is the layer of agent applications and systems. These applications run on the client device
and offer all the user interfaces.
• This tier is responsible for presenting the information to the end user. The visual presentation
Will relate to rendering on a screen. ‘Presentation Tier’ includes web browsers, WAP browsers
and customized client programs.
Communication Middleware
• It is used to connect one application to another through some communication middleware, like
connecting one application to another through telnet.
• These types of middleware are quite useful in the telecommunication world.
Transcoding Middleware
• It is used to transcode one format of data to another to suit the need of the client. Technically
Transcoding is used for content adaptation to fit the need of the device.
Enrollment No- 1
7 CE/IT 4TE07MCA1- Mobile Computing & Application
Development
• It is used to store data needed by the application and acts as a repository for both temporary and
permanent data. The data can be stored in any form of data store or database.
• These can range from sophisticated relational database, legacy hierarchical database, to even
simple text files.
• The data can also be stored in XML format for interoperability with other systems and data
sources.
• A legacy application can also be considered as a data source or document through a
Communication middleware.
Enrollment No- 2
7 CE/IT 4TE07MCA1- Mobile Computing & Application
Development
Practical: 02
To study about GSM architecture.
In System, It consists at the minimum one administrative region assigned to one MSC (Mobile
Switching Centre).
• Administrative region is commonly known as PLMN (Public Land Mobile Network).
• Each administrative region is subdivided into one or many Location Area (LA).
• One LA consists of many cell groups and each cell group is assigned to one BSC (Base
Station Controller).
• For each LA, there will be at least one BSC while cells in one BSC can belong to different
LAs.
• Cells are formed by the radio areas covered by a BTS (Base Transceiver Station). Several
BTSs are controlled by one BSC.
• Traffic from the MS (Mobile Station) is routed through MSC. Calls originating from or
terminating in a fixed network or other mobile networks is handled by the GMSC (Gateway
MSC).
• For all subscribers registered with a cellular network operator, permanent data such as the
service profile is stored in the Home Location Register (HLR). The data relate to the following
information:-
Storage of SMS Service Center (SC) number in case the mobile is not connectable so that
whenever the mobile is connectable, a paging signal is sent to the SC
o Provisioning information like whether long distance and international calls allowed or not.
o Provisioning information like whether roaming is enabled or not
o Information related to auxiliary services like Voice mail, data, fax services, etc.
o Information related to auxiliary services like CLI (Caller Line Identification), etc.
o Information related to supplementary services for call routing. In GSM network, one can
customize the personal profile to the extent that while the subscriber is roaming in a foreign
PLMN, incoming calls can be barred. Also, outgoing international calls can be barred, etc.
o Some variable information like pointer to the VLR, location area of the subscriber, Power
OFF status of the handset, etc.
Enrollment No- 3
7 CE/IT 4TE07MCA1- Mobile Computing & Application
Development
“GSM ARCHITECTURE”
• The GSM technical specifications define different entities that form the GSM network by
defining their functions and interface requirements. The GSM network can be divided into 5
main groups:-
• The Mobile Station (MS): This includes the Mobile Equipment (ME) and the Subscriber
Identity Module (SIM).
• The Base Station Subsystem (BSS): This includes the Base Transceiver Station (BTS) and the
Base Station Controller (BSC).
• The Network and Switching Subsystem (NSS): This includes Mobile Switching Center
(MSC),Home Location Register (HLR), Visitor Location Register (VLR), Equipment Identity
Register (EIR), and the Authentication Center (AUC).
• The Operation and Support Subsystem (OSS): This includes the Operation and Maintenance
Center (OMC).
• The data infrastructure that includes Public Switched Telephone Network (PSTN), Integrated
System Digital Network (ISDN), and the Public Data Network (PDN).
Enrollment No- 4
7 CE/IT 4TE07MCA1- Mobile Computing & Application
Development
Practical: 03
To study about GPRS architecture.
Introduction of GPRS
• GPRS is an abbreviation for General Packet Radio Service.
• GPRA is a means of providing packet switched data service with full mobility and wide area
coverage on GSM networks.
• The GPRS service is designed to ultimately provide data transfer up to 14.4 kBps to 171.2
KBps.
• Deployment of GPRS networks allows a variety of new applications ranging from mobile
ecommerce to mobile corporate VPN access.
• No dial-up modem connection is necessary.
• Offers fast connection set-up mechanism to offer a perception of being ‘always on’ or ‘always
connected’.
• Immediacy is one of the prime advantages of GPRS.
Enrollment No- 5
7 CE/IT 4TE07MCA1- Mobile Computing & Application
Development
• SGSN sends queries to HLR to obtain profile data of GPRS subscribers. The SGSN is
connected to the base station system with Frame Relay.
Enrollment No- 6
7 CE/IT 4TE07MCA1- Mobile Computing & Application
Development
Some existing GSM network elements must be enhanced in order to support packet data. These
are as following:
SMS Nodes
• SMS-GMSCs and SMS-IWMSCs are upgraded to support SMS transmission via the SGSN.0
• Optionally, the MSC/VLR can be enhanced for more efficient coordination of GPRS and non-
GPRS services and functionality.
• GPRS uses two frequency bands at 45 MHz apart; viz., 890-915 MHz for uplink (MS to BTS),
and 935-960 MHz for downlink (BTS to MS).
Applications of GPRS
• Advertising: It may be location sensitive. For example, a user entering a mall can receive
advertisements specific to the stores in that mall.
Enrollment No- 7
7 CE/IT 4TE07MCA1- Mobile Computing & Application
Development
Practical: 04
To study about Android. (History, Version, Architecture).
Android is a complete set of software for mobile devices such as tablet computers, notebooks,
smart phones, electronic book readers, set-top boxes etc. It contains a Linux-based Operating
System, middleware and key mobile applications.
It can be thought of as a mobile operating system. But it is not limited to mobile only. It is
currently used in various devices such as mobiles, tablets, televisions etc.
History-
1) Initially, Andy Rubin founded Android Incorporation in Palo Alto, California, United States
in October, 2003.
2) In 17th August 2005, Google acquired android Incorporation. Since then, it is in the subsidiary
of Google Incorporation.
3) The key employees of Android Incorporation are Andy Rubin, Rich Miner, Chris
White and Nick Sears.
4) Originally intended for camera but shifted to smart phones later because of low market for
camera only.
5) Android is the nick name of Andy Rubin given by coworkers because of his love to robots.
6) In 2007, Google announces the development of android OS.
7) In 2008, HTC launched the first android mobile
Versions of Android-
Enrollment No- 8
7 CE/IT 4TE07MCA1- Mobile Computing & Application
Development
The history and versions of android are interesting to know. The code names of android ranges
from A to M currently..
Enrollment No- 9
7 CE/IT 4TE07MCA1- Mobile Computing & Application
Development
1. Linux kernel
2. Native libraries (middleware),
3. Android Runtime
4. Application Framework
5. Applications
1) Linux kernel
Enrollment No- 10
7 CE/IT 4TE07MCA1- Mobile Computing & Application
Development
It is the heart of android architecture that exists at the root of android architecture. Linux
kernel is responsible for device drivers, power management, memory management, device
management and resource access.
2) Native Libraries
On the top of linux kernel, their are Native libraries such as WebKit, OpenGL, FreeType,
SQLite, Media, C runtime library (libc) etc.
The WebKit library is responsible for browser support, SQLite is for database, FreeType for font
support, Media for playing and recording audio and video formats.
3) Android Runtime
In android runtime, there are core libraries and DVM (Dalvik Virtual Machine) which is
responsible to run android application. DVM is like JVM but it is optimized for mobile devices.
It consumes less memory and provides fast performance.
4) Android Framework
On the top of Native libraries and android runtime, there is android framework. Android
framework includes Android API's such as UI (User Interface), telephony, resources, locations,
Content Providers (data) and package managers. It provides a lot of classes and interfaces for
android application development.
5) Applications
On the top of android framework, there are applications. All applications such as home, contact,
settings, games, browsers are using android framework that uses android runtime and libraries.
Android runtime and native libraries are using linux kernal.
Enrollment No- 11
7 CE/IT 4TE07MCA1- Mobile Computing & Application
Development
Practical: 05
To study about how to install Android Studio.
Setting up Android Studio takes just a few clicks.
While the Android Studio download completes, verify which version of the JDK you have: open
a command line and type javac -version. If the JDK is not available or the version is lower than
1.8, download the Java SE Development Kit 8.
Follow the setup wizard to install Android Studio and any necessary SDK tools.
On some Windows systems, the launcher script does not find where the JDK is installed. If you
encounter this problem, you need to set an environment variable indicating the correct location.
Select Start menu > Computer > System Properties > Advanced System Properties. Then
open Advanced tab > Environment Variables and add a new system variable JAVA_HOME that
points to your JDK folder, for example C:\Program Files\Java\jdk1.8.0_77.
Enrollment No- 12
7 CE/IT 4TE07MCA1- Mobile Computing & Application
Development
Enrollment No- 13
7 CE/IT 4TE07MCA1- Mobile Computing & Application
Development
Step-3
Enrollment No- 14
7 CE/IT 4TE07MCA1- Mobile Computing & Application
Development
Enrollment No- 15
7 CE/IT 4TE07MCA1- Mobile Computing & Application
Development
Enrollment No- 16
7 CE/IT 4TE07MCA1- Mobile Computing & Application
Development
Practical: 06
Learn about Android Components, Activity & Life cycle.
An android component is simply a piece of code that has a well defined life cycle e.g. Activity,
Receiver, and Service etc.
The core building blocks or fundamental components of android are activities, views, intents,
services, content providers, fragments and AndroidManifest.xml.
Activity
View
A view is the UI element such as button, label, text field etc. Anything that you see is a view.
Intent
For example, you may write the following code to view the webpage.
intent.setData(Uri.parse("http://www.javatpoint.com"));
startActivity(intent);
Enrollment No- 17
7 CE/IT 4TE07MCA1- Mobile Computing & Application
Development
Service
There are two types of services local and remote. Local service is accessed from within the
application whereas remote service is accessed remotely from other applications running on the
same device.
Content Provider
Fragment
Fragments are like parts of activity. An activity can display one or more fragments on the screen
at the same time.
AndroidManifest.xml
It contains informations about activities, content providers, permissions etc. It is like the
web.xml file in Java EE.
It is used to test the android application without the need for mobile or tablet etc. It can be
created in different configurations to emulate different types of real devices.
Android Emulator is used to run, debug and test the android application. If you don't have the
real device, it can be the best way to run, debug and test the application.
Enrollment No- 18
7 CE/IT 4TE07MCA1- Mobile Computing & Application
Development
Android R.java is an auto-generated file by aapt (Android Asset Packaging Tool) that contains
resource IDs for all the resources of res/ directory.
If you create any component in the activity_main.xml file, id for the corresponding component is
automatically created in this file. This id can be used in the activity source file to perform any
action on the component.
Enrollment No- 19
7 CE/IT 4TE07MCA1- Mobile Computing & Application
Development
By the help of activity, you can place all your UI components or widgets in a single screen.
The 7 lifecycle method of Activity describes how activity will behave at different states.
Enrollment No- 20
7 CE/IT 4TE07MCA1- Mobile Computing & Application
Development
Activity Lifecycle-
Enrollment No- 21
7 CE/IT 4TE07MCA1- Mobile Computing & Application
Development
Practical: 7
Create login application where you will have to validate e-mail id (username)
till the username and password is not validate, login button should remain
disabled. Pass username on to next screen.
MainActivity.java(login Screen)
package com.AndroidDevelopmentGuru.database_new;
import java.util.List;
import android.app.Activity;
import android.content.Intent;
import android.database.Cursor;
import android.os.Bundle;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
user =(EditText)findViewById(R.id.eduser);
pass = (EditText)findViewById(R.id.edpass);
login =(Button)findViewById(R.id.login);
not_reg =(Button)findViewById(R.id.not_reg);
login.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
Enrollment No- 22
7 CE/IT 4TE07MCA1- Mobile Computing & Application
Development
}
else{
Toast.makeText(getApplicationContext(), "Username/Password incorrect",
Toast.LENGTH_LONG).show();
Login.setEnable(View.false);
}
}
});
not_reg.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
/* @Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.action_settings, menu);
return super.onCreateOptionsMenu(menu);
//
}
*/
public boolean onOptionsItemSelected(MenuItem item) {
// Take appropriate action for each action item click
switch (item.getItemId()) {
case R.id.action_settings:
// search action
Intent i=new Intent(MainActivity.this,RegisterActivity.class);
Enrollment No- 23
7 CE/IT 4TE07MCA1- Mobile Computing & Application
Development
startActivity(i);
return true;
}
return false;
}
/* @Override
protected void onResume() {
// TODO Auto-generated method stub
list = db.getAllRegister();
// list=((alertv) alert).showAlert();
Customlist adapter = new Customlist(MainActivity.this, list);
// mylistview.setAdapter(adapter);
if(adapter.getCount()!=0){
mylistview.setAdapter(adapter);
}else{
Toast.makeText(MainActivity.this,"NoItemsAvailable",Toast.LENGTH_SH
ORT).show();
}
super.onResume();
}
*/
RegisterActivity.java
package com.AndroidDevelopmentGuru.database_new;
importandroid.R.string;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
Enrollment No- 24
7 CE/IT 4TE07MCA1- Mobile Computing & Application
Development
first= (EditText)findViewById(R.id.editfirstname);
last =(EditText)findViewById(R.id.editlastname);
email=(EditText)findViewById(R.id.editemail);
mobile =(EditText)findViewById(R.id.editmobileno);
pass=(EditText)findViewById(R.id.editpassword);
confpass=(EditText)findViewById(R.id.editconformpassword);
save=(Button)findViewById(R.id.btnsave);
cancel=(Button)findViewById(R.id.btncancel);
save.setOnClickListener(new OnClickListener() {
@Override
publicvoid onClick(View arg0) {
// TODO Auto-generated method stub
if(edConf.equals(edpass) ){
reg.setfirstName(edfirst);
reg.setlastName(edlast);
reg.setEmailId(edemail);
reg.setMobNo(edmobile);
reg.setPassword(edpass);
db.addregister(reg);
Toast.makeText(getApplicationContext(), "Registered",
Toast.LENGTH_LONG).show();
startActivity(new Intent(getApplicationContext(), MainActivity.class));
}
Enrollment No- 25
7 CE/IT 4TE07MCA1- Mobile Computing & Application
Development
else{
RegisterData.java
package com.AndroidDevelopmentGuru.database_new;
publicclass Registerdata {
//private variables
int_id;
String first_name;
String last_name;
String email_id;
String mobile_number;
public String getPassword() {
returnpassword;
}
publicvoid setPassword(String password) {
this.password = password;
}
String password;
// Empty constructor
public Registerdata(){
}
// constructor
public Registerdata(int id, String first_name, String last_name,String email_id,String
phone_number,String mobile_number){
this._id = id;
this.first_name = first_name;
Enrollment No- 26
7 CE/IT 4TE07MCA1- Mobile Computing & Application
Development
this.last_name = last_name;
this.email_id=email_id;
this.mobile_number=mobile_number;
}
// getting ID
publicint getID(){
returnthis._id;
}
// setting id
publicvoid setID(int id){
this._id = id;
}
Enrollment No- 27
7 CE/IT 4TE07MCA1- Mobile Computing & Application
Development
this.mobile_number=mobile_number;
}
}
DatabaseHandler.java
package com.AndroidDevelopmentGuru.database_new;
import java.util.ArrayList;
import java.util.List;
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
String password;
// Database Version
private static final int DATABASE_VERSION = 1;
// Database Name
private static final String DATABASE_NAME = "Mydatabase.db";
Enrollment No- 28
7 CE/IT 4TE07MCA1- Mobile Computing & Application
Development
@Override
public void onCreate(SQLiteDatabase db) {
// TODO Auto-generated method stub
db.execSQL(CREATE_TABLE);
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
// TODO Auto-generated method stub
// Drop older table if existed
db.execSQL("DROP TABLE IF EXISTS " + TABLE_REGISTER);
if(cursor.getCount()<1){
cursor.close();
Enrollment No- 29
7 CE/IT 4TE07MCA1- Mobile Computing & Application
Development
password =
cursor.getString(cursor.getColumnIndex(KEY_PASSWORD));
cursor.close();
}
return password;
Activity_main.xml
<RelativeLayoutxmlns: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"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity">
Enrollment No- 30
7 CE/IT 4TE07MCA1- Mobile Computing & Application
Development
<EditText
android:id="@+id/eduser"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="32dp"
android:ems="10"
android:hint="username(Email)">
<requestFocus/>
</EditText>
<EditText
android:id="@+id/edpass"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/eduser"
android:layout_centerHorizontal="true"
android:layout_marginTop="28dp"
android:ems="10"
android:hint="Pssword"/>
<Button
android:id="@+id/login"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/edpass"
android:layout_below="@+id/edpass"
android:layout_marginTop="43dp"
android:text="Login"/>
<Button
android:id="@+id/not_reg"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/login"
android:layout_alignBottom="@+id/login"
android:layout_alignRight="@+id/edpass"
android:text="Not Registed ?"/>
</RelativeLayout>
Activity_register.xml
Enrollment No- 31
7 CE/IT 4TE07MCA1- Mobile Computing & Application
Development
<LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/LinearLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".RegisterActivity">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/textFirstName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="FIRST NAME:"/>
<EditText
android:id="@+id/editfirstname"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="8">
<requestFocus/>
</EditText>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/textLastName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="LAST NAME:"/>
Enrollment No- 32
7 CE/IT 4TE07MCA1- Mobile Computing & Application
Development
<EditText
android:id="@+id/editlastname"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="8"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/txttextemail"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Email Id"/>
<EditText
android:id="@+id/editemail"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="8"
android:inputType="textEmailAddress"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/ txttextmobileno"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Mobile No"/>
<EditText
android:id="@+id/editmobileno"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="8"
android:inputType="phone"/>
</LinearLayout>
<LinearLayout
Enrollment No- 33
7 CE/IT 4TE07MCA1- Mobile Computing & Application
Development
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/textpassword"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="password"/>
<EditText
android:id="@+id/editpassword"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="8"
android:inputType="textPassword"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/textconformpassword"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="conform password"/>
<EditText
android:id="@+id/editconformpassword"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="8"
android:inputType="textPassword"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<Button
android:id="@+id/btnsave"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
Enrollment No- 34
7 CE/IT 4TE07MCA1- Mobile Computing & Application
Development
android:text="Save"/>
<Button
android:id="@+id/btncancel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Cancel"/>
</LinearLayout>
</LinearLayout>
Output:
Enrollment No- 35
7 CE/IT 4TE07MCA1- Mobile Computing & Application
Development
Practical: 8
activity_main.xml
<ToggleButton
android:id="@+id/toggleButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:layout_marginTop="80dp"
android:text="ToggleButton"
android:textOff="Off"
android:textOn="On"
app:layout_constraintEnd_toStartOf="@+id/toggleButton2"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<ToggleButton
android:id="@+id/toggleButton2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="60dp"
android:layout_marginTop="80dp"
android:text="ToggleButton"
android:textOff="Off"
android:textOn="On"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
Enrollment No- 36
7 CE/IT 4TE07MCA1- Mobile Computing & Application
Development
<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="144dp"
android:layout_marginLeft="148dp"
android:text="Submit"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent" />
</android.support.constraint.ConstraintLayout>
MainActivity.java
package example.javatpoint.com.togglebutton;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;
import android.widget.ToggleButton;
addListenerOnButtonClick();
}
Enrollment No- 37
7 CE/IT 4TE07MCA1- Mobile Computing & Application
Development
buttonSubmit.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View view) {
StringBuilder result = new StringBuilder();
result.append("ToggleButton1 : ").append(toggleButton1.getText());
result.append("\nToggleButton2 : ").append(toggleButton2.getText());
//Displaying the message in toast
Toast.makeText(getApplicationContext(), result.toString(),Toast.LENGTH_LONG).sh
ow();
}
});
}
}
Output:
Enrollment No- 38
7 CE/IT 4TE07MCA1- Mobile Computing & Application
Development
Practical-9
Create an android application to make call to specific entered number by user
in the Edit Text.
Mainactivity.java
package com.example.user.call;
import android.Manifest;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.support.v4.app.ActivityCompat;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
Enrollment No- 39
7 CE/IT 4TE07MCA1- Mobile Computing & Application
Development
import android.widget.Toast;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mob_no=(EditText) findViewById(R.id.mob_no);
call=(Button)findViewById(R.id.call);
call.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
call();
}
});
}
Enrollment No- 40
7 CE/IT 4TE07MCA1- Mobile Computing & Application
Development
}
}
activitymain.xml
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="phone"
android:ems="10"
android:layout_alignParentTop="true"
android:layout_alignParentStart="true"
android:id="@+id/mob_no"
android:layout_alignParentEnd="true"
android:hint="Enter ur mobile no" />
<Button
android:text="call"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/mob_no"
android:layout_alignParentStart="true"
android:layout_marginTop="78dp"
android:id="@+id/call"
android:layout_alignParentEnd="true" />
</RelativeLayout>
Androidmainfest.xml
Enrollment No- 41
7 CE/IT 4TE07MCA1- Mobile Computing & Application
Development
<uses-permission android:name="android.permission.CALL_PHONE"/>
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
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>
</application>
</manifest>
Output:
Enrollment No- 42
7 CE/IT 4TE07MCA1- Mobile Computing & Application
Development
Enrollment No- 43
7 CE/IT 4TE07MCA1- Mobile Computing & Application
Development
Practical-10
Create an android application to demonstrating grid view and web view.
1. grid view:
activity_main.xml
<GridView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:numColumns="2"
android:id="@+id/idGridView"/>
</LinearLayout>
Mainactivity.java
packagecom.example.user.demo;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.ArrayAdapter;
import android.widget.GridView;
GridView gridView;
String []data={"data1","data2","data3","data4","data5","data6","data7","data8"};
Enrollment No- 44
7 CE/IT 4TE07MCA1- Mobile Computing & Application
Development
@Override
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
gridView=(GridView)findViewById(R.id.idGridView);
gridView.setAdapter(adapter);
Output:
Enrollment No- 45
7 CE/IT 4TE07MCA1- Mobile Computing & Application
Development
2.web view:
Mainactivity.java
packagecom.example.user.demo;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
importandroid.view.View;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.Button;
importandroid.widget.EditText;
public class MainActivity extends AppCompatActivity {
EditText editText;
Button btnwebview;
@Override
@Override
});
activity_main.xml
Enrollment No- 46
7 CE/IT 4TE07MCA1- Mobile Computing & Application
Development
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="textPersonName"
android:text="Name"
android:ems="10"
android:id="@+id/idTxt"
android:layout_weight="1"
android:layout_alignParentEnd="true"
android:layout_alignParentStart="true" />
<Button
android:text="Click"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/btnWebView"
android:layout_weight="1"
android:layout_below="@+id/idTxt"
android:layout_alignParentStart="true"
android:layout_marginTop="65dp"
android:layout_alignParentEnd="true" />
<WebView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/webView"
android:layout_width="fill_parent"
android:layout_height="fill_parent"></WebView>
</RelativeLayout>
Output:
Enrollment No- 47
7 CE/IT 4TE07MCA1- Mobile Computing & Application
Development
Enrollment No- 48