Code for Midlet 1 which will call Midlet2
import java.io.IOException;
import javax.microedition.io.Connector;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Form;
import javax.microedition.midlet.*;
/**
* @author root
*/
public class pushmid extends MIDlet {
public void startApp() {
Form f = new Form("Hii");
Display d = Display.getDisplay(this);
try {
f.append("PushApp");
d.setCurrent(f);
Connector.open("socket://127.0.0.1:7777");
} catch (IOException ex) {
ex.printStackTrace();
}
}
public void pauseApp() {
}
public void destroyApp(boolean unconditional) {
}
}
.Jad file attributes for Midlet 2
MIDlet-1: newApp, , newApp
MIDlet-Jar-Size: 1066
MIDlet-Jar-URL: PushSample2.jar
MIDlet-Name: PushSample2
MIDlet-Push-1: socket://:7777,newApp,*
MIDlet-Vendor: Vendor
MIDlet-Version: 1.0
MicroEdition-Configuration: CLDC-1.1
MicroEdition-Profile: MIDP-2.0
and code in Midlet 2
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Form;
import javax.microedition.midlet.*;
/**
* @author root
*/
public class newApp extends MIDlet {
Form f = new Form("Hii");
Display d = Display.getDisplay(this);
public void startApp() {
f.append("newApp");
d.setCurrent(f);
}
public void pauseApp() {
}
public void destroyApp(boolean unconditional) {
}
}
This way Midlet 2 will be invoke when starting Midlet 1
import java.io.IOException;
import javax.microedition.io.Connector;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Form;
import javax.microedition.midlet.*;
/**
* @author root
*/
public class pushmid extends MIDlet {
public void startApp() {
Form f = new Form("Hii");
Display d = Display.getDisplay(this);
try {
f.append("PushApp");
d.setCurrent(f);
Connector.open("socket://127.0.0.1:7777");
} catch (IOException ex) {
ex.printStackTrace();
}
}
public void pauseApp() {
}
public void destroyApp(boolean unconditional) {
}
}
.Jad file attributes for Midlet 2
MIDlet-1: newApp, , newApp
MIDlet-Jar-Size: 1066
MIDlet-Jar-URL: PushSample2.jar
MIDlet-Name: PushSample2
MIDlet-Push-1: socket://:7777,newApp,*
MIDlet-Vendor: Vendor
MIDlet-Version: 1.0
MicroEdition-Configuration: CLDC-1.1
MicroEdition-Profile: MIDP-2.0
and code in Midlet 2
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Form;
import javax.microedition.midlet.*;
/**
* @author root
*/
public class newApp extends MIDlet {
Form f = new Form("Hii");
Display d = Display.getDisplay(this);
public void startApp() {
f.append("newApp");
d.setCurrent(f);
}
public void pauseApp() {
}
public void destroyApp(boolean unconditional) {
}
}
This way Midlet 2 will be invoke when starting Midlet 1
No comments:
Post a Comment