Results 1 to 3 of 3
  1. #1
    le Cauchemar is offline Member
    Join Date
    Jun 2010
    Posts
    2
    Rep Power
    0

    Default Display.setCurrent does not work

    Hey,
    I have some Problems with my program, which does not change it's screen as I want...
    I want to do following:
    When an entry of a List is selected, the mobile device connects to the internet, gets some data and displays a menu (with days in which the data is sorted).
    Some code, although I do not know what snippets could be relevant for that:
    Java Code:
    //the entry is "clicked" on
    if (c == SelectCmd) {
                    if (MainMenu.getString(MainMenu.getSelectedIndex()).equals("News"))
                    {
                        GetNews(); //gets information from web
                        ShowDays();
                    }
    //[...]
    }
    [...]
    public void ShowDays()
    {     
                if (NewsArray[0] == null) //cancel the method if there are no news - I already checked if this is called, it is not. there are news in the array
                {
                    display.setCurrent(new Alert("Keine News vorhanden"));
                    display.setCurrent(MainMenu);
                    return;
                }
                DayList.deleteAll(); //clean the List
                String datum = "";
    
                for (int x = 1; x < NewsArray.length; x++) //add day on which news were written to DayList
                {
                    if(!datum.equals(NewsArray[x].Datum))
                    {
                    
                        DayList.append(NewsArray[x].Datum, null);
                        datum = NewsArray[x].Datum;
                    }
                }
       
                display.setCurrent(DayList); //this one should work, but it does not
    }
    What happens:
    I select "News" in my menu, then the Popup appears which asks if I allow an internet connection. While it gets the news, there is still shown that popup. After a few seconds, it disappears but I'm still in my main menu...
    When I try it again (without leaving the application) it works perfectly! (Although it does exactly the same)
    Why could this happen?
    I tried anything to solve the progblem. There's no exception thrown(putting the line into a finally block does not work as well), I inserted "test code" and found out that code directly before and after the setCurrent-line are executed, so imo the setCurrent-method must be called ._.
    The only differende between the first call and later calls while runtime (which, as I wrote, work) is that Java-allow-internet-connection-alert, which only pops up the first time. Dose that cause the trouble? If so, what should I do?

    P.S.: on an emulator, it works just perfectly. there is no permission request

  2. #2
    nitinverma is offline Member
    Join Date
    Mar 2010
    Location
    New Delhi,Vadodara
    Posts
    50
    Rep Power
    0

    Default

    I think according this code,
    U r not using

    display = Display.getDisplay(this);

    Try this with ur code at the top of the code.

  3. #3
    le Cauchemar is offline Member
    Join Date
    Jun 2010
    Posts
    2
    Rep Power
    0

    Default

    I do use it first, I just didn't post the whole source, cause I thought the major part of it shouldn't matter in this case (600 lines in 1 of 6 files) :p
    And, as I wrote, it works when I try it a second time ^^
    Last edited by le Cauchemar; 06-17-2010 at 10:03 PM.

Similar Threads

  1. Replies: 1
    Last Post: 05-31-2010, 09:46 AM
  2. Replies: 8
    Last Post: 12-29-2008, 08:12 AM
  3. How do i call display.setcurrent
    By arnab321 in forum CLDC and MIDP
    Replies: 7
    Last Post: 11-04-2008, 10:00 PM
  4. Replies: 0
    Last Post: 06-28-2008, 10:26 PM
  5. how would i get this to work...?
    By deeadeed in forum New To Java
    Replies: 6
    Last Post: 12-06-2007, 03:58 AM

Posting Permissions

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