Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Contributor
yokese
Posts: 25
Registered: ‎05-19-2010
My Device: 9360
My Carrier: Vodafone

Different behaviour between 8900 and 9360 using Dialog

Hi, I have an application that have to work in both Blackberry models 8900 and 9360, but only works properly in 8900 model.

 

I have to show a popup when I click on one of the two icons entry points of the app, asking if I want to do the operation 'sent an alarm'. This operation is performed from another background process which perform this operation if I answer yes to the popup, but I don't think that this is relevant.

 

The summarized piece of code is this:

 

public class Main extends UiApplication implements GlobalEventListener, Runnable {


	public static void main(String[] args) {
		if (args.length == 1){
			.......
			
				final Main test = new Main();
		        test.invokeLater(test);
		        test.enterEventDispatcher();
		} else {
			...........
		}
	}

	public Main(){
		
		Locale.setDefault(Configuracion.load().getSelectedLocale());
		......
		createScreens();
	}

	..........
	
    public void run()
    {
        String[] choices = new String[2];
        choices[0] = Main.rb.getString(SI);
        choices[1] = Main.rb.getString(NO);
        int result = 0;
        try {
		    result = new Dialog(msg, choices,null, 0, Bitmap.getPredefinedBitmap(Bitmap.QUESTION));
	        if (result == 0) {
	        	sendAlarm();
	        }
        } catch (Exception e) {
        	Log.error(ERR_TAG + "Unexpected Exception:" + e.getMessage());
        } catch (Throwable e) {
        	Log.error(ERR_TAG + "Unexpected Exception(Throwable):" + e.getMessage());
        }
        closeNow();
    }
	
	public void sendAlarm() {
		ApplicationManager.getApplicationManager().postGlobalEvent(PIds.ID_BG, CodigosProcesoBg.SENT_ALARM, 0,  null, null);
	}
	
	public void closeNow() {

		Log.debug(LOG_TAG + "finalizando Aviso");
		exit();
	}

	............
}

 

I've used as template the code from here:

http://stackoverflow.com/questions/10620605/blackberry-show-dialog-on-startup-and-wait-until-dialog-...

 

The code works fine until the popup is showed up. Then when it's answered 'yes' in the 9360 (simulator and real device) it simply exit the app (like it has been answered 'not'). If I put a brakpoint at 'if (result == 0)' is never reached, neither any exception is thrown.

 

In model 8900 (simulator and real device) answerig yes or not, it works as expected.

 

Anyboy has some idea about this?

Please use plain text.
Developer
peter_strange
Posts: 19,601
Registered: ‎07-14-2008
My Device: Not Specified

Re: Different behavior between 8900 and 9360 using Dialog

[ Edited ]

1) I realize that we have a cut done version of your actual app, but do we have the correct code for this part?

 

       String[] choices = new String[2];
        choices[0] = Main.rb.getString(SI);
        choices[1] = Main.rb.getString(NO);
        int result = 0;
        try {
    result = new Dialog(msg, choices,null, 0, Bitmap.getPredefinedBitmap(Bitmap.QUESTION));
        if (result == 0) {

 

2) you say that the if statement is never reached, I presume the previous statement is a Dialog.ask.  Are you 100% sure that it is reached?

Please use plain text.
Contributor
yokese
Posts: 25
Registered: ‎05-19-2010
My Device: 9360
My Carrier: Vodafone

Re: Different behaviour between 8900 and 9360 using Dialog

[ Edited ]

 

Sorry, I've not posted the full version because there's many code that I'm sure that doesn't have to do with the actual problem.

 

I'm sure that the code is never reached. I've also put a trace after de the 'new Dialog....' line' and in the catch blocks an they aren't printed. I've check this with brakpoints inside Eclipse too.

 

I'm really surprised about this behaviour with 9360.

 

I'm not really stopped with this problem but I'd like a simple solution to this that would work in both models. I don't find a rational answer to this behaviour. I've coded a workaround but it involves paint two screens only to show this popup and all because of the 9360s.

 

 

 

Please use plain text.
Developer
peter_strange
Posts: 19,601
Registered: ‎07-14-2008
My Device: Not Specified

Re: Different behavior between 8900 and 9360 using Dialog

[ Edited ]

Sorry I did not explain very well.

 

This is not valid code:

 

result = new Dialog(msg,....

 

Can we see what is really there.

 

And can you tell ys if whatever is there, is actually reached. 

 

In other words, can you please show us some code that matches your code (which may not be 100% what you run but is actually workable code).  And can you tell us what the last statement that you see executed is, when you are stepping through the code. 

Please use plain text.
Contributor
yokese
Posts: 25
Registered: ‎05-19-2010
My Device: 9360
My Carrier: Vodafone

Re: Different behavior between 8900 and 9360 using Dialog

[ Edited ]

I'm very sorry, I was trying to summarize and I made a mistake copying. The correct source for method run() is this:

 

    public void run()
    {
        String[] choices = new String[2];
        choices[0] = Main.rb.getString(SI);
        choices[1] = Main.rb.getString(NO);
        int result = 0;
        try {
            Dialog dlg = new Dialog("continue?", choices,null, 0, Bitmap.getPredefinedBitmap(Bitmap.QUESTION));
            result = dlg.doModal();    
if (result == 0) { sendAlarm(); } } catch (Exception e) { Log.error(ERR_TAG + "Unexpected Exception:" + e.getMessage()); } catch (Throwable e) { Log.error(ERR_TAG + "Unexpected Exception(Throwable):" + e.getMessage()); } closeNow(); }

 

The program execution reach 'result = dlg.doModal();'; then the dialog is showed and after answering 'yes' or 'not' no more code is executed in 9360.

 

Please use plain text.