Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 49

7 CE/IT 4TE07MCA1- Mobile Computing & Application

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.

Application Tier (Tier-2)


• The application tier or middle tier is the “engine” of a ubiquitous application. It performs the
business logic of processing user input, obtaining data and making decisions.
• In certain cases, this layer will do the transcending of data for appropriate rendering in the
Presentation Tier. The application tier may include technology lie CGIs, Java, JSP, .NET
Services, PHP, etc. deployed in Apache, Web Sphere, Web Logic, Pramati etc.
• The application tier is presentation and database independent. A middleware framework is
defined as a layer of software, which sits in the middle between the OS and the user facing
software.
• We can group middleware into the following major categories:

Message-Oriented Middleware (MOM)


• It is the middleware framework that loosely connects different applications through
asynchronous exchange of messages.
• It works over a networked environment without having to know what platform or processor the
other application is resident on.

Transaction Processing (TP) Middleware


• It provides tools and an environment for developing transaction-based distributed applications.
TP is used in data management, network access, security systems, delivery order processing,
Enrollment No- 0
7 CE/IT 4TE07MCA1- Mobile Computing & Application
Development

airline reservations, customer service, etc.

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.

Distributed Object and Components


• An example of distributed objects and components is COBRA (Common Object Request
Broker Architecture).
• COBRA is an open distributed object computing infrastructure being standardized by the
Object Management Group.

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

Data Tier (Tier-3)

• 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:-

o Authentication information like IMSI.


o Identification information like name, address, etc., of the subscriber.
o Identification information like MSISDN, etc.
o Billing information like prepaid or postpaid customer.
o Operator select denial of service to a subscriber.
o Handling of supplementary services like for CFU (Call Forwarding Unconditional), CFB
(Call Forwarding Busy), CFNR (Call Forwarding Not Reachable) or CFNA (Call Forwarding
Not Answered)

 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.

Basic Quality of Service in GPRS


• Allows definition of QoS profiles using the parameters of service precedence, reliability, delay
and throughput.
• Service precedence is the priority of a service in relation to another service which can be high,
normal or low.
• Reliability indicates the transmission characteristics required by an application and guarantees
certain maximum values for the probability of loss, duplication, mis-sequencing and corruption
of packets.
• Delay parameters define maximum values for the mean delay and the 95-percentile delay.
• Throughput specifies the maximum/peak bit rate and the mean bit rate.

GPRS functional architecture and its applications-


• GPRS uses the GSM architecture for voice.
• GPRS support nodes are responsible for the delivery and routing of data packets between the
mobile stations and the external packet data networks (PDN).
There are 2 types of support nodes which are given below:

Serving GPRS Support Node (SGSN)


• A SGSN is at the same hierarchical level as the MSC. Whatever functions MSC does for the
voice,
SGSN does the same for packet data.
• SGSN’s tasks include packet switching, routing and transfer, mobility management, logical link
management, and authentication and charging functions.
• SGSN processes registration of new mobile subscribers and keeps a record of their location
inside a given service area.
• The location register of the SGSN stores location information and uses profiles of all GPRS
users registered with the SGSN.

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.

Gateway GPRS Support Node (GGSN)


• A GGSN acts as an interface between the GPRS backbone network and the external packet data
network.
• GGSN’s function is similar to that of a router in a LAN. GGSN maintains routing information
that
is necessary to tunnel the Protocol Data Units (PDUs) to the SGSNs that service particular
mobile stations.
• It converts the GPRS packets coming from the SGSN into the appropriate packet data protocol
(PDP) format for the data networks like internet or X.25, PDP sends these packets out on the
corresponding packet data network.
• The readdressed packets are sent to the responsible SGSN. For this purpose, the GGSN stores
the current SGSN address of the user and his or her profile in its location register.
• GGSN also performs authentication and charging functions related to data transfer.

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:

Base Station System (BSS)


• BSS system needs enhancements to recognize and send packet data.
• This includes BTS upgrade to allow transportation of user data to the SGSN.
• Also, the BTS needs to be upgraded to support packet data transportation between the BTS and
the MS (Mobile Station) over the radio.

Home Location Register (HLR)


• HLR needs enhancement to register GPRS user profiles and respond to queries originating
from GSNs regarding these profiles.

Mobile Station (MS)


• The mobile station or the mobile phone for GPRS is different from that of GSM.

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

• Communications: E-mail, fax, unified messaging and intranet/internet access, etc.

• Value-added services: Information services and games, etc.

• E-commerce: Retail, ticket purchasing, banking and financial trading, etc.

• Location-based applications: Navigation, traffic conditions, airline/rail schedules and location


finder, etc.

• Vertical applications: Freight delivery, fleet management and sales-force automation.

• 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

Name of Versions Of Android-

The history and versions of android are interesting to know. The code names of android ranges
from A to M currently..

Unnamed (1.0 + 1.1) [Aestro, Blender]


Cupcake (1.5)
Donut (1.6) – Quick Search Box
Éclair (2.1) – High Density Displays, Traffic + Navigation
Froyo (2.2) – Voice Control, Hotspot, Speed
Gingerbread (2.3) – Simpler, Battery Life, More apps
Honeycomb (3.0) – Flexible interface, tablets
Ice Cream Sandwich (4.0) - Customization
Jelly Bean (4.1) – Google Now, actionable notifications
KitKat (4.4) – “Ok Google”, voice control variety
Lollipop (5.0) – fluid tactile screens
Marshmallow (6.0) – battery life, app permissions, UI

Enrollment No- 9
7 CE/IT 4TE07MCA1- Mobile Computing & Application
Development

Android architecture or Android software stack is categorized into five parts:

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.

To install Android Studio on Windows, proceed as follows:

Launch the .exe file you downloaded.

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.

That's it! The following below steps..

Step-1 Start Installation by clicking on exe file-

Enrollment No- 12
7 CE/IT 4TE07MCA1- Mobile Computing & Application
Development

Enrollment No- 13
7 CE/IT 4TE07MCA1- Mobile Computing & Application
Development

Step-2 Installation cont.

Step-3

Enrollment No- 14
7 CE/IT 4TE07MCA1- Mobile Computing & Application
Development

Step-4 finished the inhalation and Initialize the workspace

Step-5 Start the first Android application.

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

An activity is a class that represents a single screen. It is like a Frame in AWT.

View

A view is the UI element such as button, label, text field etc. Anything that you see is a view.

Intent

Intent is used to invoke components. It is mainly used to:

o Start the service


o Launch an activity
o Display a web page
o Display a list of contacts
o Broadcast a message
o Dial a phone call etc.

For example, you may write the following code to view the webpage.

Intent intent=new Intent(Intent.ACTION_VIEW);

intent.setData(Uri.parse("http://www.javatpoint.com"));

startActivity(intent);

Enrollment No- 17
7 CE/IT 4TE07MCA1- Mobile Computing & Application
Development

Service

Service is a background process that can run for a long time.

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

Content Providers are used to share data between the applications.

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.

Android Virtual Device (AVD)

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.

It uses an open source processor emulator technology called QEMU.

Enrollment No- 18
7 CE/IT 4TE07MCA1- Mobile Computing & Application
Development

Internal Detail of Program-

AndroidManifest.xml file in android

The AndroidManifest.xml file contains information of your package, including components of


the application such as activities, services, broadcast receivers, content providers etc.

Android R.java file

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

Android Activity Lifecycle-

Android Activity Lifecycle is controlled by 7 methods of android.app.Activity class. The


android Activity is the subclass of ContextThemeWrapper class.

An activity is the single screen in android. It is like window or frame of Java.

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.

Android Activity Lifecycle methods-

Let's see the 7 lifecycle methods of android activity.

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;

public class MainActivity extends Activity {

EditText user, pass;


Button login, not_reg;
DatabaseHandler db;
Cursor cursor;

@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

// TODO Auto-generated method stub


db=new DatabaseHandler(MainActivity.this, null, null, 2);
String username=user.getText().toString();
String password= pass.getText().toString();

String StoredPassword =db.getregister(username);


if(password.equals(StoredPassword)){

Toast.makeText(getApplicationContext(), StoredPassword+"Login Successfully",


Toast.LENGTH_LONG).show();

}
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

startActivity(new Intent(getApplicationContext(), RegisterActivity.class));


}
});
}

/* @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;

publicclass RegisterActivity extends Activity {

EditText first, last, email, mobile, pass, confpass;


Button save, cancel;
DatabaseHandler db;
@Override

Enrollment No- 24
7 CE/IT 4TE07MCA1- Mobile Computing & Application
Development

protectedvoid onCreate(Bundle savedInstanceState) {


super.onCreate(savedInstanceState);
setContentView(R.layout.activity_register);

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

String edfirst = first.getText().toString();


String edlast = last.getText().toString();
String edemail = email.getText().toString();
String edmobile = mobile.getText().toString();
String edpass = pass.getText().toString();
String edConf = confpass.getText().toString();

if(edConf.equals(edpass) ){

db = new DatabaseHandler(RegisterActivity.this, null, null, 2);


Registerdata reg = new Registerdata();

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{

Toast.makeText(getApplicationContext(), "Password doesn't match",


Toast.LENGTH_LONG).show();
pass.setText("");
confpass.setText("");
}
}
});
}

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;
}

public String getfirstName() {


// TODO Auto-generated method stub
returnfirst_name;
}

// setting first name


publicvoid setfirstName(String first_name){
this.first_name =first_name;
}
public String getlastName() {
// TODO Auto-generated method stub
returnlast_name;
}

publicvoid setlastName(String last_name){


this.last_name =last_name;
}
public String getEmailId() {
// TODO Auto-generated method stub
returnemail_id;
}
publicvoid setEmailId(String email_id){
this.email_id =email_id;
}
public String getMobNo() {
// TODO Auto-generated method stub
returnmobile_number;
}

publicvoid setMobNo(String mobile_number){

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;

public class DatabaseHandler extends SQLiteOpenHelper {

public DatabaseHandler(Context context, Object name,


Object factory, int version) {
// TODO Auto-generated constructor stub
super(context, DATABASE_NAME, null, DATABASE_VERSION);
}

String password;
// Database Version
private static final int DATABASE_VERSION = 1;
// Database Name
private static final String DATABASE_NAME = "Mydatabase.db";

// Contacts table name


private static final String TABLE_REGISTER= "register";
public static final String KEY_ID = "id";
public static final String KEY_FIRST_NAME = " first_name";
public static final String KEY_lAST_NAME = "last_name";
public static final String KEY_EMAIL_ID="email_id";
public static final String KEY_MOB_NO = "mobile_number";
public static final String KEY_PASSWORD = "password";
public static final String CREATE_TABLE="CREATE TABLE " +
TABLE_REGISTER + "("
+ KEY_ID + " INTEGER PRIMARY KEY," +
KEY_FIRST_NAME + " TEXT,"+KEY_lAST_NAME + " TEXT,"+KEY_EMAIL_ID+ "
TEXT,"
+ KEY_MOB_NO + " TEXT," + KEY_PASSWORD + " TEXT "
+ ")";

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);

// Create tables again


onCreate(db);
}

void addregister(Registerdata registerdata)


// code to add the new register
{
SQLiteDatabase db = this.getWritableDatabase();
ContentValues values = new ContentValues();
values.put(KEY_FIRST_NAME,registerdata.getfirstName()); // register first
Name
values.put(KEY_lAST_NAME, registerdata. getlastName() ); // register last
name
values.put(KEY_EMAIL_ID, registerdata.getEmailId());//register email id
values.put(KEY_MOB_NO, registerdata.getMobNo());//register mobile no
values.put(KEY_PASSWORD, registerdata.getPassword());
// Inserting Row

db.insert(TABLE_REGISTER, null, values);


db.close(); // Closing database connection

//code to get the register


String getregister(String username){
SQLiteDatabase db = this.getReadableDatabase();
//String selectquery="SELECT * FROM TABLE_REGISTER";
Cursor cursor=db.query(TABLE_REGISTER,null, "email_id=?",new
String[]{username},null, null, null, null);

if(cursor.getCount()<1){
cursor.close();

Enrollment No- 29
7 CE/IT 4TE07MCA1- Mobile Computing & Application
Development

return "Not Exist";


}
else if(cursor.getCount()>=1 && cursor.moveToFirst()){

password =
cursor.getString(cursor.getColumnIndex(KEY_PASSWORD));
cursor.close();

}
return password;

public String getDatabaseName() {


return DATABASE_NAME;
}

public static String getKeyId() {


return KEY_ID;
}

public static String getTableContacts() {


return TABLE_REGISTER;
}

public static int getDatabaseVersion() {


return DATABASE_VERSION;
}

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

Create an android application to demonstrate toggle button.

activity_main.xml

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


<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/a
pk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="example.javatpoint.com.togglebutton.MainActivity">

<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;

public class MainActivity extends AppCompatActivity {


private ToggleButton toggleButton1, toggleButton2;
private Button buttonSubmit;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

addListenerOnButtonClick();
}

public void addListenerOnButtonClick(){


//Getting the ToggleButton and Button instance from the layout xml file
toggleButton1=(ToggleButton)findViewById(R.id.toggleButton);
toggleButton2=(ToggleButton)findViewById(R.id.toggleButton2);
buttonSubmit=(Button)findViewById(R.id.button);

//Performing action on button click

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;

public class MainActivity extends AppCompatActivity {


EditText mob_no;
Button call;
String vmob_no;

@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();
}
});
}

private void call() {


Intent i=new Intent(Intent.ACTION_CALL);
vmob_no=mob_no.getText().toString();
if(vmob_no.trim().isEmpty())
{
i.setData(Uri.parse("tel:123456789"));
}
else
{
i.setData(Uri.parse("tel:"+vmob_no));
}
if(ActivityCompat.checkSelfPermission(this,Manifest.permission.CALL_PHONE)!
=PackageManager.PERMISSION_GRANTED)
{
Toast.makeText(this,"Please grant permission to
call",Toast.LENGTH_SHORT).show();
requestPermission();
}
startActivity(i);
}

private void requestPermission() {


ActivityCompat.requestPermissions(this,new String[]
{Manifest.permission.CALL_PHONE},1);

Enrollment No- 40
7 CE/IT 4TE07MCA1- Mobile Computing & Application
Development

}
}

activitymain.xml

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


<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/activity_main"
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="com.example.user.call.MainActivity">

<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

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


<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.user.call">

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

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


<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/activity_main"
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="com.example.user.demo.MainActivity">

<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;

public class MainActivity extends AppCompatActivity {

GridView gridView;

String []data={"data1","data2","data3","data4","data5","data6","data7","data8"};

Enrollment No- 44
7 CE/IT 4TE07MCA1- Mobile Computing & Application
Development

@Override

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_main);

gridView=(GridView)findViewById(R.id.idGridView);

ArrayAdapter <String> adapter=new


ArrayAdapter<String>(this,android.R.layout.simple_list_item_1,data);

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

protected void onCreate(Bundle savedInstanceState) {


super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
editText=(EditText)findViewById(R.id.idTxt);
btnwebview=(Button)findViewById(R.id.btnWebView);
btnwebview.setOnClickListener(new View.OnClickListener() {

@Override

public void onClick(View v) {


String s=editText.getText().toString();
WebView browser=(WebView)findViewById(R.id.webview);
browser.setWebViewClient(new WebViewClient());
browser.loadUrl(s);

});

activity_main.xml

Enrollment No- 46
7 CE/IT 4TE07MCA1- Mobile Computing & Application
Development

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


<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/activity_main"
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="com.example.user.demo.MainActivity">

<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

You might also like