Mobile application development lab

May 31, 2016 | Author: Hemanth Kumar | Category: Types, Presentations
Share Embed Donate


Short Description

lab record...

Description

MOBILE APPLICATION DEVELOPMENT LAB RECORD INTRODUCTION J2ME (Java 2 Micro Edition) is an advanced technology in Java, developed with the help of Java Community Process Program. J2ME is a reduced version of the Java API and Java Virtual Machine that is designed to operate within the limited resources available in the Embedded computers and microcomputers. J2ME is targeted to developers of intelligent wireless devices and small computing devices who need to incorporate cross-platform functionality in their products. A key benefit of using J2ME is compatibility with all Java-enabled devices. Motorola, Nokia, Panasonic all have Java-enabled devices. A J2ME application is a balance between local and server-side processing. The Java Community Process Program used a two approaches to addressing the needs of small computing devices. Configurations: It is the Java run-time environment and core classes that operate on each device. A configuration defines the Java Virtual Machine for a particular small computing device. There are two configurations.

J2ME ARCHITECTURE: There are 5 layers in J2ME Architecture. 1. MIDP (Top Most Layer): Which contains Java APIs for user network connections, persistence storage, and the user interface? It also has access to CLDC libraries and MIDP libraries. 2. J2ME API’s(Profiles): Which consists of the minimum set of application programming interfaces for the small computing device 3. Configurations: Which handles interactions between the profile and the JVM? 4. JVM 5. Operating System (Bottom Layer).

MIDLETS: A MIDlet is a J2ME application which operates on an MIDP. A MIDlet is defined with at least a single class that is derived from the javax.microedition.midlet.MIDlet abstract class. A MIDlet is an event-based application. All routines executed in the MIDlet are invoked in response to an event reported to the MIDlet by the application manager. The initial event that occurs is when the MIDlet is started and the application manager invokes the startApp() method. StartApp (): called by the application manager when the MIDlet is started and contains statements that are executed each time the application begins execution. Public and have no return value nor parameter list. PauseApp (): called before the application manager temporarily stops the MIDlet. The application manager restarts the MIDlet by recalling the startApp() method. Public and have no return value nor parameter list. DestroyApp (): called prior to the termination of the MIDlet by the application manager. Public method without a return value. It has a boolean parameter that is set to true if the termination of the MIDlet is unconditional, and false if the MIDlet can throw a MIDletStateChangeException.

ROLL NO: 10U41A1224

Page 1

MOBILE APPLICATION DEVELOPMENT LAB RECORD The Basic Midlet Shell. public class BasicMIDletShell extends MIDlet { public void startApp(){ } public void pauseApp(){ } public void destroyApp( boolean unconditional){ } }

Limitations with J2ME:  Some ofthe limitations of J2ME compared with Core JAVA  Some J2SE applications require classes that are not available in J2ME.  Java applications won’t run in the J2ME environment without requiring modification to the code.  Devices that use the CDC configuration use the full Java Virtual Machine implementation, while  devices that use the CLDC configuration use the Kjava Virtual Machine implementation.  MIDlets are controlled by application management software (AMS). So we can’t invoke a MIDLET like a J2SE Application.

Sun Java Wireless Toolkit: The Sun Java Wireless Toolkit (WTK; formerly known as Java 2 Platform, Micro Edition (JavaME) Wireless Toolkit) is a state-of-the-art toolbox for developing wireless applications that are based on JavaME's Connected Limited Device Configuration (CLDC) and Mobile Information Device Profile (MIDP), and designed to run on cell phones, mainstream personal digital assistants, and other small mobile devices. The toolkit includes the emulation environments, performance optimization and tuning features, documentation, and examples that developers need to bring efficient and successful wireless applications to market quickly. The J2ME Wireless Toolkit is a comprehensive set of tools for building MIDP applications. The toolkit can be used standalone, or incorporated into many popular integrated development environments (IDEs). The Sun J2ME Wireless Toolkit supports the development of Java applications that run on devices such as cellular phones, two-way pagers, and palmtops.

ROLL NO: 10U41A1224

Page 2

MOBILE APPLICATION DEVELOPMENT LAB RECORD

Building an application with the Wireless Toolkit consists of five basic steps:  Start the toolkit, which is easier said than done. Look for the program called KToolbarif you're lost, which you probably will be your first time.  Create a new project using the Create Project button. You'll be prompted to provide the name of the project as well as the name of the main MIDlet class that should be run to start the application. The toolkit will create a project directory for you using the project name you provide.  Verify that the project properties you are shown are correct. We'll go over these in a minute.  Write your Java source in your favorite editor or IDE (or copy existing code) and save into  The src subdirectory under the main project folder.  Build your application using the Build button and use the Run button to test it in the device emulator of your choice. You'll have to download a ROM image for the Palm device emulator, but the others are included in your MIDP and CDC implementations.

ROLL NO: 10U41A1224

Page 3

MOBILE APPLICATION DEVELOPMENT LAB RECORD WEEK-1 Aim: Write a J2ME program to print the hello world?

Description: J2ME programs done by using the code java.  By using the software sun Microsoft toolkit programs can be run.  In the program first open the software.  Open the project.  Hello world program code can be write in java.  Build the project.  Run the project.  In the output the mobile or media control can be display the hello world program.  Finally output can be displayed in the mobile.

ROLL NO: 10U41A1224

Page 4

MOBILE APPLICATION DEVELOPMENT LAB RECORD SOURCE CODE: import javax.microedition.lcdui.*; import javax.microedition.midlet.MIDlet;

public class HelloWorld extends MIDlet implements CommandListener { public void startApp() { Display display = Display.getDisplay(this);

Form mainForm = new Form("HelloWorld"); mainForm.append("Welcome to the world of Mobile");

Command exitCommand = new Command("Exit", Command.EXIT, 0); mainForm.addCommand(exitCommand); mainForm.setCommandListener(this);

display.setCurrent(mainForm); }

public void pauseApp () {}

public void destroyApp(boolean unconditional) {}

public void commandAction(Command c, Displayable s) { if (c.getCommandType() == Command.EXIT) notifyDestroyed(); } }

ROLL NO: 10U41A1224

Page 5

MOBILE APPLICATION DEVELOPMENT LAB RECORD Output:

ROLL NO: 10U41A1224

Page 6

MOBILE APPLICATION DEVELOPMENT LAB RECORD WEEK-2 Aim: Write a J2ME program which creates the following kind of menu.  Cut  Copy  Paste  Delete  Select all  Unselect all

Description: J2ME programs done by using the code java.  By using the software sun Microsoft toolkit programs can be run.  In the program first open the software.  Open the project.  Hello world program code can be write in java.  Build the project.  Run the project.  In the output the mobile or media control can be display the menu creation in the first mobile .  In the second mobile the cut, copy, paste, select all, unselect all options can be displayed in second mobile.  Finally output can be displayed in the mobile.

ROLL NO: 10U41A1224

Page 7

MOBILE APPLICATION DEVELOPMENT LAB RECORD SOURCE CODE: import javax.microedition.lcdui.*; import javax.microedition.midlet.*; public class MenuCreation extends MIDlet { public ChoiceGroup ch; public Display display; public Form form; public MenuCreation() { display=Display.getDisplay(this); ch=new ChoiceGroup("Edit",Choice.EXCLUSIVE); ch.append("cut",null); ch.append("copy",null); ch.append("paste",null); ch.append("selectall",null); ch.append("unselect all",null); form=new Form("MenuCreation"); form.append(ch); } public void startApp() { display.setCurrent(form); } public void pauseApp() {} public void destroyApp(boolean unconditional) {} }

ROLL NO: 10U41A1224

Page 8

MOBILE APPLICATION DEVELOPMENT LAB RECORD Output:

ROLL NO: 10U41A1224

Page 9

MOBILE APPLICATION DEVELOPMENT LAB RECORD Week -3 Aim: Create a J2ME menu which has the following options(Event Handling): 

Cut –can be on/off



Copy –can be on/off



paste –can be on/off



delete –can be on/off



select all –pull all 4 options on



unselect all-put all

Description: J2ME programs done by using the code java.  By using the software sun Microsoft toolkit programs can be run.  In the program first open the software.  Open the project.  Hello world program code can be write in java.  Build the project.  Run the project.  In the output the mobile or media control can be display the menu event in the first mobile .  In the second mobile the cut, copy, paste, select all, unselect all options can be displayed in second mobile.  Finally output can be displayed in the mobile.

ROLL NO: 10U41A1224

Page 10

MOBILE APPLICATION DEVELOPMENT LAB RECORD SOURCE CODE: import javax.microedition.lcdui.*; import javax.microedition.midlet.*; public class MenuEvent extends MIDlet implements CommandListener, ItemStateListener { public ChoiceGroup ch; public ChoiceGroup ch1; public Form form; public Form form1; public Display display; public Command Exit; public Command View; public Command Back; public StringItem st; public Item item; public MenuEvent() { display=Display.getDisplay(this); ch=new ChoiceGroup("EDIT",Choice.MULTIPLE); ch.append("cut",null); ch.append("copy",null); ch.append("paste",null); ch.append("delete",null); form=new Form(" "); form1=new Form("selected options are "); ch.setSelectedIndex(0,true); form.append(ch); ch1=new ChoiceGroup(" ",Choice.EXCLUSIVE); ch1.append("selectall",null); ch1.append("unselectall",null); ch1.setSelectedIndex(1,true); form.append(ch1); View=new Command("View",Command.OK,1); Exit=new Command("Exit",Command.EXIT,1); ROLL NO: 10U41A1224

Page 11

MOBILE APPLICATION DEVELOPMENT LAB RECORD Back=new Command("Back",Command.BACK,1); form.addCommand(View); form.addCommand(Exit); form1.addCommand(Back); form.setCommandListener(this); form1.setCommandListener(this); form.setItemStateListener(this); } public void startApp() { display.setCurrent(form); } public void pauseApp() {} public void destroyApp(boolean unconditional) {} public void commandAction(Command command,Displayable displayable) { if(displayable==form) { if(command==View) { boolean opt[]=new boolean[ch.size()]; st=new StringItem(" "," "); String values=" "; ch.getSelectedFlags(opt); for(int i=0;i
View more...

Comments

Copyright ©2017 KUPDF Inc.
SUPPORT KUPDF