Alert problem

Hi guys! I have a problem with an Alert

I connected my phone with a database using a servlet. I would like that while it is trying to connect with the database, it will show an Alert with a gauge.

this is the code:

privatevoid infoAlert(Display display)

{

Alert info =new Alert("Information","Connecting to the server", null,null);

info.setTimeout(Alert.FOREVER);

Gauge indicator =new Gauge (null,false,Gauge.INDEFINITE,Gauge.CONTINUOUS_RUNNING);

info.setIndicator(indicator);

display.setCurrent(info);

}

I call this method when i try to connect the phone with the server:

try

{

http = (HttpConnection) Connector.open(url);

http.setRequestMethod(HttpConnection.GET);

if (http.getResponseCode() == HttpConnection.HTTP_OK)

{

infoAlert(display);

byte servletData[]=null;

input = http.openInputStream();

int length = (int) http.getLength();

if (length > 0)

{

...................

.....................

................

servletData =newbyte[length];

input.read(servletData);

.......................

.......................

}

when I get back the data from the server the display will show the form that contains them

It work on the emulator but on my phone it doesn't work and i got this exception: java.lang.IllegalArgumentException: Alert cannot return to Alert

I also tryied info.setTimeout(5000);

but it doesn't work!!!!

please could someone help me? Tell me where I do some mistake or tell me some other way to do it?

thanks

antonio

[2349 byte] By [antonio5982@libero.ita] at [2007-11-27 4:21:43]
# 1

Why don't you try the other setCurrent() method?

public void setCurrent ( Alert alert, Displayable nextDisplayable )

This asks for the alert to be displayed and on it's dismissal, nextDisplayable should be displayed.

I think the problem in your code is here:

display.setCurrent(info);

After it returns, on the emulator it probably displays the last displayable but on the phone it possibly requires you to specify explicitly.

Chage it to something else; and possibly, you should change your logic a bit. Don't make it's timeout FOREVER since the user would be able to dismiss that. You should probably use a form that the user can't dismiss and then change the displayed forms dynamically after you get the data from the servlet. Remeber, alerts can be dismissed no matter what, whether timed or FOREVER. So your user could potentially be dismissing the alert before your form is ready.

So what you could do is this, show an alert, timed or FOREVER and then show a form with the gauge running with no commands so the user can't change. And once you're done with your data retrieval, programmatically change the currentdisplay.

nogoodatcodinga at 2007-7-12 9:28:53 > top of Java-index,Java Mobility Forums,Java ME Technologies...
# 2
Yes, you are right! The problem was as you wrote!Thank you for your help!Antonio
antonio5982@libero.ita at 2007-7-12 9:28:53 > top of Java-index,Java Mobility Forums,Java ME Technologies...