You Are Here:

Community: Developer Discussion Boards

Reply « Previous Thread | Next Thread »

#1 Old Angry Midlet Suite Problem - 2009-06-30, 11:07

Join Date: Jun 2009
Posts: 15
Biz
Offline
Registered User
Hi there,

I created an application with 2 midlets, MIDlet_1 and MIDlet_2 in a midlet suite. MIDlet_1 triggers MIDlet_2(which plays some music) at a certain time set in MIDlet_1.

I installed my application in a Phone.

However, when I open the application, and when I choose MIDlet_1, 1st it goes out of the application for a few secs and then only enters MIDlet_1.

Would anyone kindly tell me why that happens and why can't it go directly to MIDlet_1?

If I create I MIDlet and a simple class and not a midlet for MIDlet 2, I have no such problem. But in that case I cannot automate MIDlet_2.

Is it because the vendor of my application is unknown? Any solutions to this problem.

Any kind of response is welcome.
Reply With Quote

#2 Old Re: Midlet Suite Problem - 2009-06-30, 11:15

Join Date: Mar 2008
Posts: 2,161
Location: The Capital of I N D I A
Send a message via Skype™ to raj_J2ME
raj_J2ME's Avatar
raj_J2ME
Offline
Forum Nokia Champion
Hi Biz,
Where are you actually calling the midlet-2,inside the midlet-1?
Please explain the same much more details.Are the both midlet in same midlet suite?


Thanks

R a j - The K e r n e l
Reply With Quote

#3 Old Re: Midlet Suite Problem - 2009-06-30, 11:29

Join Date: Jul 2008
Posts: 329
Location: Faridabad(Delhi NCR)
Send a message via MSN to ansh.chauhan Send a message via Yahoo to ansh.chauhan
ansh.chauhan's Avatar
ansh.chauhan
Offline
Regular Contributor
Quote:
Originally Posted by Biz View Post
Hi there,

I created an application with 2 midlets, MIDlet_1 and MIDlet_2 in a midlet suite. MIDlet_1 triggers MIDlet_2(which plays some music) at a certain time set in MIDlet_1.

I installed my application in a Phone.

However, when I open the application, and when I choose MIDlet_1, 1st it goes out of the application for a few secs and then only enters MIDlet_1.

Would anyone kindly tell me why that happens and why can't it go directly to MIDlet_1?

If I create I MIDlet and a simple class and not a midlet for MIDlet 2, I have no such problem. But in that case I cannot automate MIDlet_2.

Is it because the vendor of my application is unknown? Any solutions to this problem.

Any kind of response is welcome.
It seem to me really confusing please express it in little bit better way.


Anshu Chauhan
J2me Developer
Reply With Quote

#4 Old Thumbs up Re: Midlet Suite Problem - 2009-06-30, 12:09

Join Date: Jun 2008
Posts: 96
Send a message via AIM to sharvan1981
sharvan1981's Avatar
sharvan1981
Offline
Regular Contributor
Quote:
Originally Posted by Biz View Post
Hi there,

I created an application with 2 midlets, MIDlet_1 and MIDlet_2 in a midlet suite. MIDlet_1 triggers MIDlet_2(which plays some music) at a certain time set in MIDlet_1.

I installed my application in a Phone.

However, when I open the application, and when I choose MIDlet_1, 1st it goes out of the application for a few secs and then only enters MIDlet_1.

Would anyone kindly tell me why that happens and why can't it go directly to MIDlet_1?

If I create I MIDlet and a simple class and not a midlet for MIDlet 2, I have no such problem. But in that case I cannot automate MIDlet_2.

Is it because the vendor of my application is unknown? Any solutions to this problem.

Any kind of response is welcome.
plz explain your problem.
Reply With Quote

#5 Old Re: Midlet Suite Problem - 2009-06-30, 13:09

Join Date: Jun 2003
Posts: 4,325
Location: Cheshire, UK
grahamhughes's Avatar
grahamhughes
Offline
Forum Nokia Champion
Quote:
Originally Posted by Biz View Post
MIDlet_1 triggers MIDlet_2
How does this happen?

You are not allowed to do this:

Code:
MIDlet mid2 = new MIDlet_2();
mid2.startApp();
Only the application manager can create MIDlet objects.

If you are trying to use registerAlarm(), remember that your device might not be able to run two MIDlets at the same time, so running MIDlet_1 will prevent MIDlet_2 from starting.

Graham.
Reply With Quote

#6 Old Thumbs up Re: Midlet Suite Problem - 2009-06-30, 14:26

Join Date: Sep 2008
Posts: 1,195
Location: DELHI
Send a message via Yahoo to jitu_goldie
jitu_goldie's Avatar
jitu_goldie
Offline
Forum Nokia Champion
Quote:
Originally Posted by Biz View Post
Hi there,

I created an application with 2 midlets, MIDlet_1 and MIDlet_2 in a midlet suite. MIDlet_1 triggers MIDlet_2(which plays some music) at a certain time set in MIDlet_1.

I installed my application in a Phone.

However, when I open the application, and when I choose MIDlet_1, 1st it goes out of the application for a few secs and then only enters MIDlet_1.

Would anyone kindly tell me why that happens and why can't it go directly to MIDlet_1?

If I create I MIDlet and a simple class and not a midlet for MIDlet 2, I have no such problem. But in that case I cannot automate MIDlet_2.

Is it because the vendor of my application is unknown? Any solutions to this problem.

Any kind of response is welcome.
How are u invoking the midlet2 :
1. with the help of Push registry , or
2. by making an object of another midlet ie midlet2.

Please mention ur problem in detail..
or post ur code for both midlet1 and midlet2.


thanks,
jitu_goldie..

KEEP TRYING..
Reply With Quote

#7 Old Re: Midlet Suite Problem - 2009-07-02, 10:18

Join Date: Jun 2009
Posts: 15
Biz
Offline
Registered User
Hello Everyone,

Thank you for your kind responses and sorry for not being able to explain my problem well. I will try to do it again.

I am trying to use registerAlarm() method in push registry API to triger Alarm MIDlet through Pust MIDlet where I set the time for the Alarm. Alarm MIDlet uses class SoundPlayer to play and stop the music.

Push MIDlet
Code:
import java.util.Date;

import javax.microedition.io.PushRegistry;
import javax.microedition.lcdui.Alert;
import javax.microedition.lcdui.AlertType;
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.DateField;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.Form;
import javax.microedition.lcdui.Item;
import javax.microedition.lcdui.ItemStateListener;
import javax.microedition.midlet.MIDlet;
import javax.microedition.midlet.MIDletStateChangeException;

/**
 * Push MIDlet automates the Alarm MIDlet
 */
public class Push extends MIDlet implements ItemStateListener,CommandListener {

	private Display display; // Reference to display object
	private Form form; // The main form
	private Command cmAlarm; // Start the timer
	private Command cmReset; // Reset to current date/time

	private DateField dfAlarmTime; // How long to sleep
	private Date currentTime; // Current time...changes when pressing reset
	private boolean dateOK = false; // Was the user input valid?



	public Push() {
		System.out.println( "Push: constructor" );

		display = Display.getDisplay(this);

		// The main form
		form = new Form("Set Alarm");

		// Save today's date
		currentTime = new Date();

		// DateField with todays date as a default

		dfAlarmTime = new DateField("", DateField.DATE_TIME);
		dfAlarmTime.setDate(currentTime);

		// All the commands/buttons
		cmAlarm = new Command("Save", Command.SCREEN, 1);
		cmReset = new Command("Reset", Command.SCREEN, 1);


		// Add to form and listen for events
		form.append("Set Date and Time\n");
		form.append(dfAlarmTime);
		form.addCommand(cmAlarm);
		form.addCommand(cmReset);

		form.setCommandListener(this);
		form.setItemStateListener(this);
		display.setCurrent(form);
	}


	public void startApp() throws MIDletStateChangeException{

		System.out.println( "Push: startApp" );


		System.out.println( "Push: startApp: return" );

	}

	
	public void pauseApp() {
		System.out.println( "Push: pauseApp" );
	}

	
	public void destroyApp( boolean unconditional ) {
	}

	public void itemStateChanged(Item item) {
		if (item == dfAlarmTime) {
		
			if (dfAlarmTime.getDate().getTime() < currentTime.getTime())
				dateOK = false;
			else
				dateOK = true;
		}
	}

	public void commandAction(Command c, Displayable s) {
		if (c == cmAlarm) {

			if (dateOK == false) {
				Alert al = new Alert("Unable to set alarm","Please choose another date and time.", null, null);
				al.setTimeout(Alert.FOREVER);
				al.setType(AlertType.ERROR);
				display.setCurrent(al);
			} else {
				long amount = dfAlarmTime.getDate().getTime() - currentTime.getTime()-10000;
				System.out.println( "aaa"+amount+"\n" );
				scheduleMIDlet(amount);		
				System.out.println( "Push: destroyApp" );
				destroyApp(false);
				notifyDestroyed();
			}
		} else if (c == cmReset) {
			// Reset to the current date/time
			dfAlarmTime.setDate(currentTime = new Date());
		} 
	}

	private void scheduleMIDlet (long delt)
	{
		System.out.println( "Inside Scheduler\n" );
		System.out.println( "aaa"+delt+"\n" );
		try {

			Date	now	= new Date();

			PushRegistry.registerAlarm("Alarm", now.getTime() + delt);

		} catch ( java.lang.ClassNotFoundException cnf ) {
			System.out.println( "Push: Class not Found" );
		} catch ( javax.microedition.io.ConnectionNotFoundException connnf ) {
			System.out.println( "Push: Connection Not Found" );
		}

	}


}
Alarm MIDlet
Code:
import java.util.Date;

import javax.microedition.midlet.*;
import javax.microedition.io.PushRegistry;
import javax.microedition.lcdui.*;
 
public class Alarm extends MIDlet implements CommandListener{
	private Display display; // Reference to display object
	private Form form; // The main form
	private Ticker t; 
	private Image image;
	private ImageItem img;
	
	private Command cmExit; // Exit Appli
	private Command cmStop; // Stop Alarm
	private SoundPlayer soundPlayer = new SoundPlayer();
	
	public Alarm(){
		
		display = Display.getDisplay(this);
		form = new Form("");
		
		t = new Ticker ("★ Rise and Shine ★");
		form.setTicker (t);
		
		image = null;
		try { image = Image.createImage("/bell.png");
		}catch (Exception e){
		}
		img = new ImageItem("",image ,Item.LAYOUT_2|Item.LAYOUT_CENTER|Item.LAYOUT_VCENTER,"",Item.PLAIN );
		form.append(img);
		
		cmExit = new Command("Exit", Command.EXIT, 1);
	    cmStop = new Command("Stop", Command.SCREEN, 1);
	    form.addCommand(cmExit);
        form.addCommand(cmStop);
        form.setCommandListener(this);
        
		display.setCurrent(form);
		soundPlayer.playsound("Play");
	}

	protected void destroyApp(boolean unconditional) throws MIDletStateChangeException {
		// TODO Auto-generated method stub
		
	}

	protected void pauseApp() {
		// TODO Auto-generated method stub
		
	}

	protected void startApp() throws MIDletStateChangeException {
		// TODO Auto-generated method stub
		
	}

	public void commandAction(Command c, Displayable arg1) {
		// TODO Auto-generated method stub
		if (c == cmExit) {
            try {
            	soundPlayer.playsound("Stop");
            	destroyApp(false);
				
			} catch (MIDletStateChangeException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
            notifyDestroyed();
        } else if (c == cmStop){
        	soundPlayer.playsound("Stop");
		} 
	}
	
	
	
}
SoundPlayer
Code:
import java.io.InputStream;

import javax.microedition.media.Manager;
import javax.microedition.media.Player;

/*This is a class that plays music for Alarm*/

public class SoundPlayer {

    public Player  player;
    public InputStream in= null;
        
    
    public SoundPlayer() {        
        try {   
        	in = getClass().getResourceAsStream("/Shuffle A-Tak_2-01.mp3");
            player=Manager.createPlayer(in,"audio/mpeg");
            player.prefetch();
        } catch (Exception e) {
            e.printStackTrace();
        }
}
    public void playsound(String playtype) {
        
    	//Play
    	if (playtype.compareTo(new String("Play")) == 0) {
    		try {

    			player.start();
    		} catch (Exception e) {
    			System.out.println("xxxxxxxxxxS");
    			e.printStackTrace();
    		}  
    	}
       
        
       //Stop
        if (playtype.compareTo("Stop") == 0) {   
       	 try {
                player.stop();
                player.setMediaTime(0);
                System.out.println("!!!!!!!!!!!!!!!");
            } catch (Exception e) {
           	 System.out.println("!!!!!!!!!!!!!!!***********");
           	 e.printStackTrace();
            }  	
       }        
    }     
}
The JAD file looks like this:
Code:
MIDlet-1: Push,,Push
MIDlet-2: Alarm,,Alarm
MIDlet-Jar-Size: 412205
MIDlet-Jar-URL: Push_Registry1.jar
MIDlet-Name: Push Registry1 Midlet Suite
MIDlet-Permissions: javax.microedition.io.PushRegistry
MIDlet-Vendor: Midlet Suite Vendor
MIDlet-Version: 1.0.0
MicroEdition-Configuration: CLDC-1.1
MicroEdition-Profile: MIDP-2.0
After I install the application (Push Registry MIDlet Suite with 2 midlets and 1 class) to the phone, when I try to start it from the place where I saved,
It shows 2 selection Menu,
1.Push
2.Alarm

When I select Push I expect it to enter to the Push MIDlet where I can do the Alarm Setting, however 1st it goes back to the place where the application is stored and then only enters the Push MIDlet. This will definately confuse the 1st time user. Is it because the MIDlet vendor is unknown?

Am I clear this time?

Hoping to get responses.

Regards:)
Reply With Quote

#8 Old Re: Midlet Suite Problem - 2009-07-02, 11:13

Join Date: Mar 2008
Posts: 2,161
Location: The Capital of I N D I A
Send a message via Skype™ to raj_J2ME
raj_J2ME's Avatar
raj_J2ME
Offline
Forum Nokia Champion
Quote:
After I install the application (Push Registry MIDlet Suite with 2 midlets and 1 class) to the phone, when I try to start it from the place where I saved,
It shows 2 selection Menu,
1.Push
2.Alarm
I must say that you are using the s60 devices for the testing.This series devices display the same like the above quoted line,

Quote:
When I select Push I expect it to enter to the Push MIDlet where I can do the Alarm Setting, however 1st it goes back to the place where the application is stored and then only enters the Push MIDlet. This will definately confuse the 1st time user. Is it because the MIDlet vendor is unknown?
About the red lines,I am not sure.Could you please explain the same,


Thanks

R a j - The K e r n e l
Reply With Quote

#9 Old Thumbs up Re: Midlet Suite Problem - 2009-07-02, 13:09

Join Date: Sep 2008
Posts: 1,195
Location: DELHI
Send a message via Yahoo to jitu_goldie
jitu_goldie's Avatar
jitu_goldie
Offline
Forum Nokia Champion
Quote:
After I install the application (Push Registry MIDlet Suite with 2 midlets and 1 class) to the phone, when I try to start it from the place where I saved,
It shows 2 selection Menu,
1.Push
2.Alarm

When I select Push I expect it to enter to the Push MIDlet where I can do the Alarm Setting, however 1st it goes back to the place where the application is stored and then only enters the Push MIDlet. This will definately confuse the 1st time user. Is it because the MIDlet vendor is unknown?

Am I clear this time?

Hoping to get responses.
what do u mean by that?
May be ur problem is two midlets shown at the menu of device and may be u r confuse to choose the right midlet to enter the application. Is it so?


thanks,
jitu_goldie..

KEEP TRYING..
Reply With Quote

#10 Old Re: Midlet Suite Problem - 2009-07-02, 13:21

Join Date: Mar 2008
Posts: 2,161
Location: The Capital of I N D I A
Send a message via Skype™ to raj_J2ME
raj_J2ME's Avatar
raj_J2ME
Offline
Forum Nokia Champion
Hi,
Jitu read his post,and check the midlet flow,he is selecting the correct midlet,


Thanks

R a j - The K e r n e l
Reply With Quote

#11 Old Re: Midlet Suite Problem - 2009-07-02, 19:13

Join Date: Jul 2008
Posts: 329
Location: Faridabad(Delhi NCR)
Send a message via MSN to ansh.chauhan Send a message via Yahoo to ansh.chauhan
ansh.chauhan's Avatar
ansh.chauhan
Offline
Regular Contributor
HI raj
But what he want to do it hard to understand.
hey buddy what exactly you want tell us


Anshu Chauhan
J2me Developer
Reply With Quote

#12 Old Thumbs up Re: Midlet Suite Problem - 2009-07-03, 06:36

Join Date: Sep 2008
Posts: 1,195
Location: DELHI
Send a message via Yahoo to jitu_goldie
jitu_goldie's Avatar
jitu_goldie
Offline
Forum Nokia Champion
Quote:
Originally Posted by raj_J2ME View Post
Hi,
Jitu read his post,and check the midlet flow,he is selecting the correct midlet,
Im just guessing the problem of original poster. Im not quite able to understand his problem that's why im just asking him.


thanks,
jitu_goldie..

KEEP TRYING..
Reply With Quote

#13 Old Re: Midlet Suite Problem - 2009-07-03, 06:38

Join Date: Mar 2008
Posts: 2,161
Location: The Capital of I N D I A
Send a message via Skype™ to raj_J2ME
raj_J2ME's Avatar
raj_J2ME
Offline
Forum Nokia Champion
Quote:
Originally Posted by ansh.chauhan View Post
HI raj
But what he want to do it hard to understand.
hey buddy what exactly you want tell us
Hi,
I recommend that you should also read the post by scrolling down the page,this is all explained in the post 1 of this thread.
Quote:
But what he want to do it hard to understand.
If you will read the post carefully then you will understand the same.


Thanks

R a j - The K e r n e l
Reply With Quote

#14 Old Re: Midlet Suite Problem - 2009-07-03, 08:14

Join Date: Jun 2009
Posts: 15
Biz
Offline
Registered User
Hello Everyone again,

Lets say I stored Push Registry with many other application (Alarm, Calendar, Timer, Sudoku), I cannot show how the screen on phone exaclty looks like, but I will simply "draw" screen transition diagram by words here.

1)Press Application folder : The screen looks like below:

Application
Push Registy MIDlet Suite
Alarm
Calendar
Timer
Sudoku

2) Press Pust Registry MIDlet Suite : The screen looks like below:

Push Registy MIDlet Suite
Alarm
Push

3) Press Push : The screen looks like below, 1st it goes to screen "a" for 2 sec and then only moves to screen "b"

a)
Application
Push Registy MIDlet Suite
Alarm
Calendar
Timer
Sudoku

b)
Set Alarm
Set Date and Time
03-Jul-09
15:08:00

My problem is, in No.3 when I press Push i want to go directly to screen "b".

I am sorry but, this is the best I can explain:(

I hope it is clear this time

Regards

P.S: Please address me with a "she"
Reply With Quote

#15 Old Re: Midlet Suite Problem - 2009-07-03, 12:25

Join Date: Jun 2003
Posts: 4,325
Location: Cheshire, UK
grahamhughes's Avatar
grahamhughes
Offline
Forum Nokia Champion
Hello!!

I understand now.

You go to the "application menu", where you see a list of MIDlet suites (JAR files). Then you select your suite. Because your suite has two MIDlets, you next see a list of MIDlets in the suite. You select a MIDlet, and you (briefly) see the "application menu" again, before the application starts. Is that correct?

To some extent, this is a function of the device. There may be nothing you can do about it.

It is important to keep the amount of code in the MIDlet constructor, in static initializers, and in the startApp() method, to a minimum. Reducing the amount of code that is executed during start up may reduce the time. However, you don't appear to have much code.

One alternative is to have only one MIDlet. Unfortunately, there is no method to find out if the MIDlet was started from the menu, or by the Alarm. The best you can achieve it to store the registered alarm time in RMS and, at start up, check to see:

Code:
if (currentTime >= alarmTime && currentTime < (alarmTime + TIME_WINDOW_SIZE)) {
    // assume we were started by the alarm
} else {
    // assume we were started from the application menu
}
Where "TIME_WINDOW_SIZE" is some limit within which you expect the alarm to be trigered (say, five minutes). This is quite a clumsy mechanism, but there is no nice way.

Otherwise, I think you have to live with the application menu appearing for a moment. You will find that different devices will behave differently. What you are seeing is a quirk of that particular device.

Graham.
Reply With Quote
Reply « Previous Thread | Next Thread »
Display Modes
Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules

You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Forum Jump
Similar Threads
Thread Thread Starter Forum Replies Last Post
MIDlet: Connection bluetooth problem Wulfric Bluetooth Technology 4 2009-01-23 15:30
Got Problem with PC Suite damien77 PC Suite API and PC Connectivity SDK 6 2006-04-14 05:04
PC Suite Problem Please Help! dj_raw PC Suite API and PC Connectivity SDK 5 2006-04-12 07:04
launching MIDlet from another MIDlet on 6310i problem niko86 Mobile Java General 1 2002-08-07 10:38
loading ressources using nokia midlet suite b_varasse Mobile Java General 0 2002-05-16 12:32

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia