Mobile Application Programming LAB

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 65

MOBILE

APPLICATION
PROGRAMMING
LAB
CONTENT

S.NO DATE NAME OF THE PROGRAM PAGE SIGN


NO

1 STUDY OF J2ME SIMULATOR

2 SIMPLE CALCULATOR

3 CALENDAR

4 TIMER

5 SIMPLE GAME

6 ANIMATION IMAGE

7 PERSONAL PHONEBOOK

8 AUTHENTICATION AND
ENCRYPTION TECHNIQUE

9 BROWSING THE INTERNET

10 STUDY OF GLOMOSIM
SIMULATOR
EX.NO: 1
DATE:

STUDY OF J2ME SIMULATOR

AIM:
To study about WML and J2ME simulator.

Java 2 Platform, Micro Edition(J2ME)


Introduction:
Traditional computing devices use fairly standard hardware
configurations such as display, keyboard,large amount of memory
and permanent storage. However new breed of computing devices
lacs hardware configuration. J2ME is specially designed for
developing applications for small computing devices such as cell
phones, PDA etc.
J2ME Configurations:
Configuration defines the JVM for a particular small computing
device.
Types:
Two types of configuration haves been defined.
1) CLDC (Connected limited Device configuration) CLDC is used for the
devices with the limited resources. CLDC devices use stripped version of JVM
called KVM. CLDC devices are mobile phones,PDA etc.
2) CDC ( Connected device configuration) CDC devices use complete JVM.
CDC devices are set-top box, Home appliances.
Java Virtual Machine layer:
This layer is an implementation of a Java Virtual Machine that is
customized for a particular device's host operating system and supports a
particular J2ME configuration.
Configuration layer:
The configuration layer defines the minimum set of Java Virtual Machine
features and Java class libraries available on a particular category of devices. In
a way, a configuration defines the commonality of the Java platform features
and libraries that developers can assume to be available on all devices belonging
to a particular category.
Profile layer:
The profile layer defines the minimum set of application
programming interfaces (APIs) available on a particular family of devices.
Profiles are implemented upon a particular configuration.
MIDP layer:
The Mobile Information Device Profile (MIDP) is a set of Java APIs
that addresses issues such as user interface, persistence storage, and networking.
MIDlet Programming:
A MIDlet is class , which is controlled by the application manager. A
MIDlet class must contain three abstract methods that are called by application
manager.
public class class-name extends MIDlet
{
public void startApp(){ }
public void pauseApp() { }
public void destroyApp( unconditional boolean) { }
}
Steps for creating a MIDlet suite:
1) Select a file system where you want to create a MIDlet suite. Right click on
it, a pop up menu appears. From the pop up menu, select New -> MIDlet Suite.
2) Enter the Name of MIDlet suite. Click on Next.
3) Enter the package and class name and To add existing MIDlet ,click on
brows , select the MIDlet to be added. J2ME It also allows you to select icon for
the given MIDlet.
4) Click Finish.
Wireless Markup Language (WML)
Introduction:
The Wireless Markup Language (WML) is the HTML of WAP browsers
and is transmitted via the HTTP protocol.
WML is a markup language built specifically for communicating across
WAP-based networks, and is based upon XML (eXtensible Markup Language).
Like HDML, it is at first glance similar to HTML, but is also a much more
strictly written language.
The advantage of the WML language is the fact that, since it is a subset
of XML, developer's can easily kill two birds with one stone by building both
the web page and wireless device page simultaneously. While this is still
possible with HDML code, it is certainly not as obvious and workarounds must
be introduced
Why Should we use WML
Although you might not have any plans immediately for creating a
WAP version of your site, it is always a good idea to get involved in new
technology. All you need to do is make a small site (even one page) which tells
people a bit about your website. In the future you can develop the site further
with things like e-mail and information for people to get directly off their
phones.
The main sites which will benefit from WAP are ones providing
a service like e-mail, live sports scores or a calendar service etc. but there are
many other uses. For example, a site giving music reviews could put their
reviews on a WAP site. People could then read the reviews on their mobile
phone while browsing through the CDs in a shop.
WML Decks and Cards
WML pages are called DECKS. They are constructed as a set of
CARDS, related to each other with links. When a WML page is accessed from a
mobile phone, all the cards in the page are downloaded from the WAP server.
Navigation between the cards is done by the phone computer - inside the phone
- without any extra access trips to the server.
<?xml version="1.0"?>
!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN"
"http://www.techiwarehouse.com/DTD/wml_1.1.xml">
<wml>
<card id="HTML" title="HTML Tutorial">
< p> You can learn WML in 30 Days
</p>
</card>
< card id="XML" title="XML Tutorial">
< p> You can also learn how to make an WAP based Page
< /p>
</card>
</wml>

WML TAGS
WAP homepages are not very different from HTML homepages.
The markup language used for WAP is WML (Wireless Markup Language).
WML uses tags just like HTML - but the syntax is stricter and conforms to the
XML 1.0 standard. WML pages have the extension *.WML, just like HTML
pages have the extension *.HTML

CONCLUSION
WAP is programmed in wireless markup language WML (application
of XML) and WMLScript (WAP's version JavaScript) which is embedded in
client's mobile. WML provides a simple event mechanism that allows different
content to be displayed. User actions, such as pressing a key, can be tied to
scripts that cause changes in content. The WML browser also has this timer
function that can load a different page or trigger the change of variables when
the time is up. This provide great flexibility than the static content that HTML
can deliver.
EX.NO: 2
DATE:

SIMPLE CALCULATOR

AIM:
To write the program for implementing the simple calculator having +, -,
* and / using J2ME.

ALGORITHM:

STEP-1 : Start the process.


STEP-2 : The midlet class has been imported a class of calculator.
STEP-3 : Required datafields are initialized.
STEP-4 : Arithmetic operations are declared in different module to
do their process.
STEP-5: The Command Listener used invoke the command
then commandaction used to perform the
arithmetic operation.
STEP-6: Stop the process.
CALCULATOR

package hello;
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
public class Midlet extends MIDlet implements CommandListener {
Display dis;
Form frm;
TextField x,y;
Command add,sub,mul,div,clr;
StringItem res;
public void startApp() {
dis=Display.getDisplay(this);
frm=new Form("Calculator");
add=new Command("Addition",Command.ITEM,1);
sub=new Command("Subtraction",Command.ITEM,1);
mul=new Command("Multiply",Command.ITEM,1);
div=new Command("Division",Command.ITEM,1);
clr=new Command("Clear",Command.ITEM,1);
x=new TextField("Enter the value","",30,1);
y=new TextField("Enter the value","",30,1);
frm.addCommand(add);
frm.addCommand(sub);
frm.addCommand(mul);
frm.addCommand(div);
frm.addCommand(clr);
frm.append(x);
frm.append(y);
res=new StringItem("Result","");
frm.append(res);
frm.setCommandListener(this);
dis.setCurrent(frm);
}
public void pauseApp() {
}
public void destroyApp(boolean unconditional) {
}
public void commandAction(Command c, Displayable d) {
String m=c.getLabel();
if(m.equals("Addition"))
{
int a,b;
a=Integer.parseInt(x.getString());
b=Integer.parseInt(y.getString());
res.setLabel("addition");
res.setText("Result"+(a+b));
}
else
if(m.equals("Subtraction"))
{
int a,b;
a=Integer.parseInt(x.getString());
b=Integer.parseInt(y.getString());
res.setLabel("Subtraction");
res.setText("Result"+(a-b));
}
else
if(m.equals("Multiply"))
{
int a,b;
a=Integer.parseInt(x.getString());
b=Integer.parseInt(y.getString());
res.setLabel("Multiply");
res.setText("Result"+(a*b));
}
else
if(m.equals("Division"))
{
int a,b;
a=Integer.parseInt(x.getString());
b=Integer.parseInt(y.getString());
res.setLabel("Division");
res.setText("Result"+(a/b));
}
else
{
x.setString("");
y.setString("");
}
}
}
OUTPUT:
RESULT:
Thus the program for implementing the calculator in mobile was
successfully executed and verified.
EX.NO: 3
DATE:

CALENDAR

AIM:
To write the program for implementing the calendar for any given month
and year using J2ME.

ALGORITHM:

STEP-1: Start the process.


STEP-2: Import the package for executing of the program in class
calendar extency class Midlet the class implements
the CommadListener and ItemStateListener.
STEP-3: Private date member initialized.
STEP-4: Inintialized and design data to the field we need to display.
STEP-5: Use calendar as constructor the required function or call.
STEP-6: The start application called to append the data and display
The form.
STEP-7: Distroy append and also reallocate the memory, notify the
Destroy function.
STEP-8: Stop the process.
CALENDAR
package hello;
import java.util.TimeZone;
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;

public class Midlet extends MIDlet implements


CommandListener,ItemStateListener{
Display dis;
Form frm;
DateField dt,dt_time;
public void startApp() {
dis=Display.getDisplay(this);
dt=new DateField("Select your Date",DateField.DATE);
dt_time=new
DateField("Time",DateField.DATE_TIME,TimeZone.getDefault());
frm=new Form ("Date picker");
frm.append(dt);
frm.append(dt_time);
dis.setCurrent(frm);
frm.setCommandListener(this);
frm.setItemStateListener(this);
}
public void CommandAction(Command c,Displayable d){
}
public void pauseApp() {
}
public void destroyApp(boolean unconditional) {
}
public void commandAction(Command c, Displayable d) {
throw new UnsupportedOperationException("Not supported yet.");
}
public void itemStateChanged(Item item) {
throw new UnsupportedOperationException("Not supported yet.");
}
}
OUTPUT:
RESULT:
Thus the program for implementing the calendar in
mobile was successfully executed and verified.
EX.NO: 4
DATE:

TIMER

AIM:
To write the program for implementing the Timer to System Time using
J2ME.

ALGORITHM:

STEP-1: Start the process.


STEP-2: Import the package for executing of the program in class Midlet
and it implements the CommandListener,ItemStateListener.
STEP-3: In the snooze function set the datefield and commands are
assigned for snooze, reset and exit.
STEP-4: Add command these function and call the command function set
the alarm time for alarm.
STEP-5: Set the snooze timer to schedule remove the command snooze
time for alarm.
STEP-6: Snooze and alart time for the alarm snooze current time.
STEP-7: Stop the process.
TIMER
package hello;

import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
import java.util.Timer;
import java.util.TimerTask;
import java.util.*;
public class Midlet extends MIDlet implements
CommandListener,ItemStateListener {
Display dis;
Form frm;
Command snooze,reset,exit;
DateField dfsnoozetime;
int dateindex;
Date currentdate;
Timer tmsnooz;
snoozeTimer Timerttsnooze;
boolean dateOK=false;
public Midlet()
{
dis=Display.getDisplay(this);
frm=new Form("timer");
currentdate=new Date();
dfsnoozetime=new DateField("",DateField.DATE_TIME);
dfsnoozetime.setDate(currentdate);
snooze=new Command("snooze",Command.SCREEN,1);
reset=new Command("reset",Command.SCREEN,1);
exit=new Command("exit",Command.EXIT,1);
dateindex=frm.append(dfsnoozetime);
frm.addCommand(snooze);
frm.addCommand(reset);
frm.addCommand(exit);
frm.setCommandListener(this);
frm.setItemStateListener(this);
}
public void startApp()
{
dis.setCurrent(frm);
}
public void ItemStatechanged(Item i)
{
if(i==dfsnoozetime)
{
if(dfsnoozetime.getDate().getTime()<currentdate.getTime())
{
dateOK=false;
}
else
{
dateOK=true;
}
}
}
public void CommandAction(Command c,Displayable d)
{
if(c==snooze)
{
if(dateOK=false)
{
Alert al=new Alert("Unable to set Alerms");
al.setTimeout(Alert.FOREVER);
al.setType(AlertType.ERROR);
dis.setCurrent(al);
}
else
{
tmsnooz=new Timer();
Timerttsnooze=new snoozeTimer();
long amount=dfsnoozetime.getDate().getTime()-
currentdate.getTime();
tmsnooz.schedule(Timerttsnooze,amount);
frm.removeCommand(snooze);
frm.removeCommand(reset);
frm.delete(dateindex);
frm.setTitle("snooze...");
}
}
else if(c==reset)
{
dfsnoozetime.setDate(currentdate=new Date());
}
else if(c==exit)
{
destoryApp(false);
notifyDestroyed();
}
}

private void destoryApp(boolean b) {


throw new UnsupportedOperationException("Not yet implemented");
}
protected void pauseApp() {
throw new UnsupportedOperationException("Not supported yet.");
}

public void commandAction(Command c, Displayable d) {


throw new UnsupportedOperationException("Not supported yet.");
}

public void itemStateChanged(Item item) {


throw new UnsupportedOperationException("Not supported yet.");
}

protected void destroyApp(boolean unconditional) throws


MIDletStateChangeException {
throw new UnsupportedOperationException("Not supported yet.");
}

private class snoozeTimer extends TimerTask


{
public final void run()
{
Alert al=new Alert("Time to wakeup");
al.setTimeout(Alert.FOREVER);
al.setType(AlertType.ALARM);
AlertType.ERROR.playSound(dis);
dis.setCurrent(al);
cancel();
}
}
}
OUTPUT:
RESULT :
Thus the program for implementing the system timer in
mobile was successfully executed and verified.
EX.NO: 5
DATE:

SIMPLE GAME

AIM:
To write the program for implementing simple game using J2ME.

ALGORITHM:

STEP-1: Start the process.


STEP-2: Import the package for executing of the program in class Midlet
and it implements the CommandListener,ItemStateListener.
STEP-3: Initialize and display data to the field we need to display.
STEP-4: In class rescanvas to access the paint function for graphics, set
the color two are more in the frame.
STEP-5: Get the color code from the user and check the code is match or
not.
STEP-6: If it match to the color code increase score as 5 otherwise it
decreased.
STEP-7: Stop the process.
GAME:

package game;
import javax.microedition.lcdui.*;
import javax.microedition.midlet.*;
import java.util.Random;

public class Midlet extends MIDlet implements CommandListener {


Display display;
Command start;
private StringItem rscore;
private TextField in1;
int score=0;
int show ;
String col1,col2;
public void startApp()
{
Canvas canvas = new CanvasLine();
display = Display.getDisplay(this);
start=new Command("Start Game",Command.ITEM, 1);
canvas.addCommand(start);
canvas.setCommandListener(this);
display.setCurrent(canvas);
}

public void pauseApp() {


}
public void destroyApp(boolean unconditional) {
}
class rescanvas extends Canvas
{
public void paint(Graphics g) {

int width = getWidth();


int height = getHeight();
g.setColor(0,0,255);
g.fillRect(0, 0, width, height);
g.setColor(255,0,0);
g.drawString("Result Is:",0,0, 0);
}
}
class CanvasLine extends Canvas {
public void paint(Graphics g) {
int width = getWidth();
int height = getHeight();
g.setColor(255,255,255);
g.fillRect(0, 0, width, height);
g.setColor(22,45,67);
g.drawString("Memory Test Game",20,0, 0);
Random rand = new Random();
int r1 =rand.nextInt(255);
int g1 = rand.nextInt(255);
int b1 = rand.nextInt(255);
g.setColor(r1,g1,b1);
g.drawString("Colour Memo 1:"+r1+"-"+g1+"-"+b1,90,30, 0);
col1=r1+"-"+g1+"-"+b1;
g.fillRect(10, 40, 50, 50);
int r2 =rand.nextInt(255);
int g2 = rand.nextInt(255);
int b2 = rand.nextInt(255);
g.setColor(r2,g2,b2);
g.drawString("Colour Memo 2:"+r2+"-"+g2+"-"+b2,90,80, 0);
col2=r2+"-"+g2+"-"+b2;
g.fillRect(10, 100,50, 50);
g.drawString("Score is: "+score,100,150, 0);
}
}
public void commandAction(Command c, Displayable d) {
String m= c.getLabel();
if(m=="Start Game")
{
Form res=new Form("Game Memory Calculate");
Command check=new Command("Check",Command.OK,1);
Command back=new Command("Back",Command.BACK,1);
Random rand = new Random();
show=rand.nextInt(2);
in1=new TextField("Colour Code "+show+" (R-G-B)", "",20, 1);
res.append(in1);
res.addCommand(back);
res.addCommand(check);
res.setCommandListener(this);
display.setCurrent(res);
}
else if(m=="Check")
{
Form m1=new Form("Score Board");
Command back1=new Command("Back",Command.BACK,1);
m1.addCommand(back1);
m1.setCommandListener(this);
if(show==1)
{
if(col1.equalsIgnoreCase(in1.getString()))
{
rscore=new StringItem("Correct Match", col1 +"--->" +
in1.getString());
score+=5;
m1.append(rscore);
}
else
{
rscore=new StringItem("Wrong Match",col1 +"--->" +
in1.getString());
score-=5;
m1.append(rscore);
}
}
else if(show==2)
{
if(col2.equalsIgnoreCase(in1.getString()))
{
rscore=new StringItem("Correct Match", col2 +"--->" +
in1.getString());
score+=5;
m1.append(rscore);
}
else
{
rscore=new StringItem("Wrong Match",col2 +"--->" +
in1.getString());
score-=5;
m1.append(rscore);
}
}
else
{
rscore=new StringItem("No Match ,Try Again","");
m1.append(rscore);
}
display.setCurrent(m1);
}
else if(m=="Back")
{
CanvasLine res=new CanvasLine();
Command back=new Command("Back",Command.BACK,1);
start=new Command("Start Game",Command.ITEM, 1);
res.addCommand(start);
res.addCommand(back);
res.setCommandListener(this);
display.setCurrent(res);
}
}
}
OUTPUT:
RESULT:
Thus the program for implementing the system timer in mobile was
successfully executed and verified.
EX.NO: 6
DATE:

ANIMATION

AIM:
To write the program for implementing the calendar for any given month
and year using J2ME.

ALGORITHM:

STEP-1: Start the process.


STEP-2: Import the package for executing of the program in class Midlet
and it implements the CommandListener,ItemStateListener.
STEP-3: Set the grayscale image of the arc
STEP-4: Sweepcanvas class is used for representing arc as initialized
degree as 90,120,180,360.
STEP-5: Stop the process.
ANIMATION:
package image;
import java.util.Timer;
import java.util.TimerTask;
import javax.microedition.lcdui.*;
import javax.microedition.midlet.MIDlet.*;
public class Midlet extends MIDlet implements CommandListener {
private Display display;
protected boolean started;
private Command exitCommand;
private Command setupCommand;
private Command runCommand;
private Form form;
private sweepcanvas canvas;
private Gauge blockGauge;
private Gauge rateGauge;
private static final int FRAME_RATE = 1;
private static final int BLOCK_COUNT = 1;
protected void startApp() {
if (!started) {
display = Display.getDisplay(this);
form = new Form("Animation");
rateGauge = new Gauge("Frame rate", true, 10, FRAME_RATE);
blockGauge = new Gauge("Blocks", true, 4, BLOCK_COUNT);
form.append(rateGauge);
form.append(blockGauge);
canvas = new sweepcanvas();
exitCommand = new Command("Exit", Command.EXIT, 0);
setupCommand = new Command("Setup", Command.SCREEN, 0);
runCommand = new Command("Run", Command.SCREEN, 0);
canvas.addCommand(exitCommand);
canvas.addCommand(setupCommand);
form.addCommand(exitCommand);
form.addCommand(runCommand);
form.setCommandListener(this);
canvas.setCommandListener(this);
display.setCurrent(form);
started = true;
}
}
protected void pauseApp() {
}
protected void destroyApp(boolean unconditional) {
}
public void commandAction(Command c, Displayable d) {
if (c == exitCommand) {
notifyDestroyed();
} else if (c == runCommand) {
display.setCurrent(canvas);
} else if (c == setupCommand) {
display.setCurrent(form);
}
}
}
public class sweepcanvas extends Canvas implements Runnable
{
private boolean mtrucking;
private int mtheta;
private int mBorder;
private int mDelay;
public sweepcanvas()
{
mtheta=100;
mBorder=10;
mDelay=100;
}
public void start()
{
mtrucking=true;
Thread t=new Thread(this);
t.start();
}
public void stop()
{
mtrucking=false;
}
public void paint(Graphics g)
{
int w=getWidth();
int h=getHeight();
g.setGrayScale(255);
g.fillRect(0,0,w-1,h-1);
int x=mBorder;
int y=mBorder;
int w1=w-mBorder*2;
int h1=h-mBorder*2;
for( int i=0;i<8;i++)
{
g.setGrayScale((8-i)*32-16);
g.fillArc(x,y,w1,h1,mtheta+i*20,10);
g.fillArc(x,y,w1,h1,(mtheta+180)%360+i*20,10);
}
}
public void run()
{
while(mtrucking)
{
mtheta=(mtheta+1)%360;
try
{
Thread.sleep(2000);
repaint();
}
catch(Exception e){}
}
}
}
}
OUTPUT:
RESULT:
Thus the program for implementing the games in mobile was
successfully executed and verified.
EX.NO: 7
DATE:

PERSONAL PHONE BOOK

AIM:
To write the program for implementing the personal phonebook
containing the name,phone no,address,e-mail using J2ME.

ALGORITHM:

STEP-1: Start the process.


STEP-2: Import the package which are all used for the application.
STEP-3: Inside the start app function for searching of contact difference
function are called.
STEP-4: On any error in the drive the exception in carryout.
STEP-5: The pass application and destroy application is using
MIDLET class.
STEP-6: Command action function is called to handle the command.
STEP-7: Local contact function is called lead the contact information.
STEP-8: Stop the process.
PHONE BOOK:
package phone_book;

import javax.microedition.io.CommConnection;
import javax.microedition.lcdui.*;
import javax.microedition.midlet.*;
import javax.microedition.rms.*;
public class Midlet extends MIDlet implements CommandListener{
private Display display;
private ChoiceGroup searchgroup;
private Form searchform;
private TextField searchtextField;
private Command exitcmd;
private Command searchcmd;
private Command addContactcmd;
private Form addcontactForm;
private TextField nametxtField,numberTextField;
private Command backcmd;
private Command saveCmd;
private String nameStr;
private String numberStr;
private Alert addalert;
private RecordStore openRecStore;
public void startApp() {
display=Display.getDisplay(this);
searchform=new Form("Search Contact");
searchtextField=new TextField("Search Here", "", 30,TextField.ANY);
searchform.append(searchtextField);
searchgroup=new ChoiceGroup("",Choice.EXCLUSIVE);
searchform.append(searchgroup);
exitcmd=new Command("Exit",Command.EXIT,7);
searchform.addCommand(exitcmd);
addContactcmd=new Command("Add",Command.OK,4);
searchform.addCommand(addContactcmd);
searchcmd=new Command("Search", Command.ITEM, 2);
searchform.addCommand(searchcmd);
searchform.setCommandListener(this);
display.setCurrent(searchform);
addcontactForm=new Form("Add Contact");
nametxtField=new TextField("Name","", 80,TextField.ANY);
numberTextField=new TextField("Number","",80,
TextField.PHONENUMBER);
addcontactForm.append(nametxtField);
addcontactForm.append(numberTextField);
backcmd=new Command("Back",Command.BACK,2);
addcontactForm.addCommand(backcmd);
saveCmd=new Command("Save",Command.OK,4);
addcontactForm.addCommand(saveCmd);
addcontactForm.setCommandListener( this);
try
{
openRecStore=RecordStore.openRecordStore("Contacts", true);
}catch(RecordStoreException ex){ex.printStackTrace();}
loadcontact();
}
public void pauseApp() {
}
public void destroyApp(boolean unconditional) { }

public void commandAction(Command c, Displayable d) {

if(c==exitcmd)
{
notifyDestroyed();
}else if(c==addContactcmd)
{
nametxtField.setString("");
numberTextField.setString("");
display.setCurrent(addcontactForm);
}
else if (c==backcmd)
{
searchtextField.setString("");
display.setCurrent(searchform);
}
else if (c==saveCmd)
{
nameStr=nametxtField.getString();
numberStr=numberTextField.getString();
addalert=new Alert("Added to the Contact");
loadcontact();
display.setCurrent(addalert,searchform);
searchtextField.setString("");
String fulldetail=nameStr+"*"+numberStr;
byte[] bytearray=fulldetail.getBytes();
try
{
openRecStore.addRecord(bytearray, 0, fulldetail.length());
}
catch(RecordStoreException ex){ex.printStackTrace();}
loadcontact();
}
else if (c==searchcmd)
{
addalert=new Alert("Search Found");
searchcontact(searchtextField.getString().toString());
display.setCurrent(addalert,searchform);
searchtextField.setString("");
}
}
public void loadcontact()
{
searchgroup.deleteAll();
try
{
RecordEnumeration enuRec=openRecStore.enumerateRecords(null,
null, true);
while(enuRec.hasNextElement())
{
try
{
byte[] nextrec=enuRec.nextRecord();
String nextRecStr=new String(nextrec);
String takename=nextRecStr.substring(0,nextRecStr.indexOf("*"));
Stringtakenumber=nextRecStr.substring(nextRecStr.indexOf("*")+1
,nextRecStr.length());
searchgroup.append(takename+"-"+takenumber, null);
}
catch(RecordStoreException ex){ex.printStackTrace();}
}
}
catch(RecordStoreException ex){ex.printStackTrace();}
}
public void searchcontact(String str)
{
searchgroup.deleteAll();
try
{
RecordEnumeration enuRec=openRecStore.enumerateRecords(null,
null, true);
while(enuRec.hasNextElement())
{
try
{
byte[] nextrec=enuRec.nextRecord();
String nextRecStr=new String(nextrec);
String takename=nextRecStr.substring(0,nextRecStr.indexOf("*"));
String takenumber=nextRecStr.substring(nextRecStr.indexOf("*")+1
,nextRecStr.length());
if(str.equalsIgnoreCase(takename))
{
searchgroup.append(takename+"-"+takenumber, null);
}
}
catch(RecordStoreException ex){ex.printStackTrace();}
}
}
catch(RecordStoreException ex){ex.printStackTrace();}
}
}
OUTPUT:
RESULT:
Thus the program for implementing the animation in mobile was
successfully executed and verified.
EX.NO: 8
DATE:

AUTHENICATION AND ENCRYPTION


TECHNIQUES

AIM:
To write the program for implementing the authentication and encryption
technique used in GSM.

ALGORITHM:

STEP-1: Start the process.


STEP-2: Import the package which are all used for the application.
STEP-3: Get key value for the string item then encript the value using en().
STEP-4: Get key value for the string item that decript the value using de().
STEP-5: Stop the process.
AUTHENTICATION AND ENCRYPTION:

package encryption;

import javax.microedition.lcdui.*;
import javax.microedition.lcdui.TextField;
import javax.microedition.midlet.*;
public class Midlet extends MIDlet implements CommandListener{
StringItem s;
Form f;
Display disply;
TextField txt1;
public void startApp() {
disply=Display.getDisplay(this);
f=new Form("Encryption/Decryption(Character)");
txt1=new TextField("Plain Text", "", 20, 0);
Command encrypt,decrypt;
encrypt=new Command("Encrypt",Command.ITEM, 1);
decrypt=new Command("Decrypt",Command.ITEM, 2);
f.append(txt1);
f.addCommand(encrypt);
f.addCommand(decrypt);
s=new StringItem("Result", "");
f.append(s);
f.setCommandListener(this);
disply.setCurrent(f);
}
public void pauseApp() {
}
public void destroyApp(boolean unconditional) {
}
public void commandAction(Command c, Displayable d) {
String k=c.getLabel();
if(k.equalsIgnoreCase("Encrypt"))
{
f=new Form("Encryption/Decryption");
String res=en(txt1.getString());
s=new StringItem("Encrypt Result", res);
f.append(s);
disply.setCurrent(f);
}

if(k.equalsIgnoreCase("Decrypt"))
{
f=new Form("Encryption/Decryption");
s=new StringItem("Decrypt Result",
""+de(Integer.parseInt(txt1.getString())));
f.append(s);
disply.setCurrent(f);
}

}
String en(String x)
{
String m="";
for(int i=0;i<x.length();i++)
{
m=m+"-"+getkey(x.charAt(i));
}
return m;
}

public int getkey(char a)


{
int c=0;
c=(int)a;
return c;
}
char de(int x)
{
char m1;
m1=(char)x;
return m1;
}
}
OUTPUT:
RESULT:
Thus the program for implementing the encriptiion and decription
technique using GSM in mobile was successfully executed and verified.
EX.NO: 9
DATE:

BROWSING THE INTERNET

AIM:
To write the program for browsing the internet using mobile phone
simulator.

ALGORITHM:

STEP-1: Start the process.


STEP-2: Import the package which are all used for the application.
STEP-3: Get the URL address from the user .
STEP-4: Pass the search command and it diplay the form.
STEP-5: Connect the url using platform request function.
STEP-6: Access the history field for reference.
STEP-7: Stop the process.
BROWSING INTERNET
package accessurl;

import java.io.*;
import javax.microedition.io.*;
import javax.microedition.lcdui.*;
import javax.microedition.midlet.*;

public class Midlet extends MIDlet implements CommandListener{


private Display display;
String url = "";
TextField txt;
public Midlet(){
display = Display.getDisplay(this);
}

public void startApp()


{
Form frm=new Form("Web Browser");
txt=new TextField("URL", "",50, 1);
Command srch=new Command("Search", Command.OK,1);
frm.append(txt);
frm.addCommand(srch);
frm.setCommandListener(this);
display.setCurrent(frm);
}
public void pauseApp(){}
public void destroyApp(boolean unconditional){}
void connection(String url) throws IOException{
TextBox access;
try
{
access = new TextBox("History", url, 1024, 0);
}finally{
}
platformRequest(url);
display.setCurrent(access);
}

public void commandAction(Command c, Displayable d) {


String x=c.getLabel();
if(x=="Search")
{
try
{
connection(txt.getString());
}catch(Exception e){}
}
}
}
OUTPUT:
RESULT:
Thus the program for implementing the browsing the internet
in mobile was successfully executed and verified.
EX.NO: 10
DATE:

STUDY OF GLOMO SIM SIMULATOR

AIM:
To study the concept of Glomo sim Simulator.

INTRODUCTION TO GLOMOSIM:

1. Introduction

With GloMoSim we are building a scalable simulation environment


for wireless network systems. It is being designed using the parallel discrete-
event simulation capability provided by Parsec. Most network systems are
currently built using a layered approach that is similar to the OSI seven layer
network architecture.
The plan is to build GloMoSim using a similar layered approach.
Standard APIs will be used between the different simulation layers. This will
allow the rapid integration of models developed at different layers by different
people. The goal is to build a library of parallelized models that can be used for
the evaluation of a variety of wireless network protocols. The proposed protocol
stack will include models for the channel, radio, MAC, network, transport, and
higher layers.

1.1 Network Gridding


simple approach to designing a network simulation would be to
initialize each network node in the simulation as a Parsec entity. We can view
different entity initializations as being separate logical processes in the system.
Hence each entity initialization requires its own stack space in the runtime. In
GloMoSim, we are trying to build a simulation that will scale to thousands of
nodes. If we have to instantiate an entity for each node in the runtime, the
memory requirements would increase dramatically. The performance of the
system would also degrade rapidly. Since there are so many entities in the
simulation, the runtime would need to constantly context switch among the
different entities in the system. This will cause significant degradation in the
performance of the simulation. Hence initializing each node as a separate entity
will inherently limit the scalability and performance of the simulation.
To circumvent these problems network gridding was introduced into the
simulation. With network gridding, a single entity can simulate several network
nodes in the system. A separate data structure representing the complete state of
each node is maintained within the entity. Similarly we need to maintain the
right level of abstraction. When the simulation code of a particular node is being
executed it should not have access to the data structures of the other nodes in
the simulation. In GloMoSim, each entity represents a geographical area of the
simulation. Hence the network nodes which a particular entity represents are
determined by the physical position of the nodes.
Suppose we specify the following in the input file:

#
SIMULATION-RANGE-X 100
SIMULATION-RANGE-Y 100
#
# Number of partitions in x and y range.
PARTITION-NUM-X 2
PARTITION-NUM-Y 2
#

We would now have a simulation are of size (100 * 100). We would also have 4
partitions (each partition is represented by a single entity) in the simulation. So
one partition would encompass the square area represented by the coordinates
(0, 0), (49, 0), (0, 49), and (49, 49).
1.2 Layered Structure
Since we are building GloMoSim using a layered approach, we would like to
have the ability to rapidly integrate models developed at different layers by
different people. Hence the simple approach here would seem to be that each
layer in the simulation would be represented by a different Parsec entity. We
would still have the same problem that we had previously. As the number of
layers in the simulation increases, the number of entities in the simulation
would also increase. This would lead to scalability and performance problems in
the simulation. But this is not as dramatic since there are only a few layers in
the simulation. But there are other reasons why we need to aggregate the layers
into a single entity.

2. Directory Structure of GloMoSim.


After downloading and upzipping GloMoSim, it should contain the following
directories:
/applicaiton contains code for the application layer
/bin for executable and input/output files
/doc contains the documentation
/include contains common include files
/mac contains the code for the mac layer
/main contains the basic framework design
/network contains the code for the network layer
/radio contains the code for the physical layer
/transport contains the code for the transport layer
You have to compile the files from the main/ directory.
o Run "make depend" to create list of depndencies in the Makefile.
o Make sure that the right path for the Parsec compiler is specified in the
Makefile
for the "PAR" variable.
o Run "make" to create the executable
You can also use Makent.bat for compiling in batch mode (for NT).
To run the simulation you have to go to the bin/ directory. The executable is
called "Sim". It taked only one command line paramter, which is an input file.

3. Description of input file.


This section explains the various parameters which are part of the input file
supplied to the GloMoSim executable. In the input file anything following a "#"
is treated as a comment. Note that some parameters presented in this section
may not be valid in the latest GloMoSim library as we keep updating the library
to be configured easily. The "config.in" file included in the distribution should
be the most up-to-date configuration file and used as a template file.

CONCLUSION:
Here the glomo simulator has been evaluated with the range of small
time manipulation. So every part of delivery standards can be modified easily.

You might also like