08-19-2008 07:01 AM
In my application, i am showing some EditField, LabelField, and ButtonField on my MainScreen. Now because of some event my app goes into background and start observing some events while remaining in background.
Now on certain event my app removes existing fields from the MainScreen adds new fields to display while remaining in background. Subsequently i go to my app and click it to bring it in foreground. I still see previous fields on the MainScreen which were shown before my app went into background.
I am using deleteAll() method of Manager to delete all fields before adding new fields and doPaint() method of Screeb to paint all fields again. But my logic is not working.
Can someone through some light on what may be the problem ?
08-19-2008 07:19 AM
What you are doing seems reasonable, though I'm not sure about the doPaint(), why would you bother when the screen is in the background?
I would do some very thorough debugging to make sure the problem is not in your code. I would specifically check that you don't have two instances of your screen (which is how I've seen this problem in my own code), and that the code you run in the background works when executed from a menu (i.e. in foreground).
08-19-2008 10:03 AM
08-29-2008 07:30 AM
invalidate also doesn't work.
I am changing fields on the screen when i receive phonecall events in my listener class. And i don't think there are two different instances of my screen being created because i am able to show a Dialog.alert pop message on the screen from my background app but within same method when i can change fields they are not reflected.
08-29-2008 08:43 AM
I take it that you can reproduce this problem easily on the Simulator?
You make the comment that you don't have two different instances because you see the Dialog. I don't think that proves that you don't have two instances. I would put a debug point in when the Fields are being updated, and note the Screen Object referenced there (note the @... value). I would also put a debug point in your display code somewhere, and make sure that the screen there is the same @... value.
Have you tried my second suggestion, to prove that the code you run in the background works when executed from a menu (i.e. in foreground)? You will probably need to comment out your real, callLog interrogating code and put in some dummy code, say to just add a new label with the current time in it, but I think this would be a useful test.
You may not be aware, but the Listener call runs under control of a different Application than yours. I must admit that I have never tried updating Screens belonging to one Application, from a different Application, which is effectively what you are doing. Perhaps this results in an Exception, presumably an IllegalStateException. Have you checked that you don't get any exceptions in your Phone Listener code? Perhaps you could move the Dialog so that it is the last thing the code does - then if you get an exception, you won't see the Dialog, which makes it easy to test.
Finally, I must add that I have never had a problem like this (and I've had a few) that wasn't actually something in my own code. But in case it is OS Level specific, can you tell me what level of JDE you are using. Again, I'm assuming that you can reproduce this on the Simulator.
08-29-2008 10:26 AM
09-01-2008 07:18 AM
i am not able to test my app on simulator as i am having another issue which i have been discussing on the other thread of this forum
But i did check by moving Dialog statement at the end. And your understanding is right, i didn't see the dialog this time. So may be there is some exception.
So how do i see the exception on device and more importantly how do i change field from the listener's code if its being executed in someother thread?
Thanks Peter, i am glad that i have started seeing some dim light at the end of the tunnel :-)
09-01-2008 08:26 AM
You should see the Exception in the Device's Log. You can see the log by going to the Home Screen, then holding the ALT key down and pressing "L", then "G", then "L", then "G". Then release the Alt key and you should see a list. You can scroll down this list, Exceptions are normally listed in Bold.
Alternatively debug this by attaching the Device to the PC you have the JDE on, and then attach the device to the JDE (Debug Menu, select Attach To, then USB, then the device). This may actually allow you to step through the code. If you don't have a 'try catch', it will also display the Exception.
Alternatively, do this the hard way and put a number of load of "try catches" around each of the bits of code that were after your Dialog and are now before. In the catch, put in an output statement like
System.out.println("just done <put in here the statement> and got exception: " + e.toString);
You will see this in the JDE Debugger window. Or you could display a Dialog with the Exception details in it.
You should, using one of the above methods, be able to find out the error and the line it occurs on. Then see if you can fix it!
How do you change into your own application to update the Field? I run a thread in my own UiApplication.
To do this I have to add a reference to my UiApplication in RuntimeStore, then just do something like:
UiApplication myUiApp = <Reference from RuntimeStore>;
myUiApp.invokeLater(.<code to update my Fields>.);
Hope that makes sense.