1. Shreyas's Avatar
    Hi all,

    I m changing the app. icon using HomeScreen.updateIcon(bitmap) when app. is in background.

    Now how to fire click event when I click on this new app. icon like when I click on previous app. icon (which is set through Project Properties-> Resources) main() is invoked.

    I have set my main project as CLDC app & m using an alternative entry point which is started at startup but dont have any Resources.

    Any system defined Class is there to handle this updatedIcon issue?
    11-04-09 06:51 AM
  2. QuiteSimple's Avatar
    Changing the icon with updateIcon() does not change anything else. If the user clicks the icon, the code execution will go through your main method, as it worked with the original icon.
    11-08-09 02:18 AM
  3. Shreyas's Avatar
    Ok. Thanks for the reply.
    11-09-09 12:18 AM
  4. Shreyas's Avatar
    now I m setting an int var. in RuntimeStore when updates app. icon like,

    Code:
    public static long RS_ID = 0x837b99e982d67bdfL;
    
    HomeScreen.updateIcon(bitmap);
    
    RuntimeStore rs = RuntimeStore.getRuntimeStore();
    rs.put(ClassName.RS_ID, new Integer(1));
    now in main(), can i write it like,

    Code:
    public static void main( String[] args )
    {       
        if( args.length > 0 && args[0].equals( "autostartup" ) )
        {
            IconTest iconTest = new IconTest();        
                .............   
                iconTest.enterEventDispatcher();
        }
        else
        {
                // Start a new app instance for GUI operations.
            IconTest iconTest = new IconTest(); 
            iconTest.showGui();
        }
    }
    
    
    private void showGui()
    {
    
          RuntimeStore rs = RuntimeStore.getRuntimeStore();
          int appIconState = rs.get(ClassName.RS_ID);
          if (appIconState == 1)           //updated app. icon
         {
                  Screen2 scr2 = new Screen2();     
                  pushScreen(scr2);
         }
         else                             //old app. icon                          
         {
                Screen1 scr1 = new Screen1();       
                pushScreen(scr1);
         }                          
          enterEventDispatcher();
    }
    11-09-09 04:23 AM
  5. QuiteSimple's Avatar
    Nice idea! Now I got what you mean You will start different screens depending on the icon type, that's smart
    11-09-09 05:23 AM
  6. Shreyas's Avatar
    Yes. Thats exactly what i m trying to do..

    So is my way of doing it correct ?
    Last edited by Shreyas; 11-10-09 at 12:04 AM.
    11-10-09 12:02 AM
  7. QuiteSimple's Avatar
    On a first glance, it should work.
    11-10-09 04:11 AM
  8. Shreyas's Avatar
    But when I click on updatedIcon, its not coming to main(). it says,

    Starting AppName
    AppName already running

    & directly it goes to first screen.

    what i want is "When clicked on updatedIcon a particular screen should be opened & when the user goes back to Main Menu the app should get its original Icon & app name & the flow shold go through main() when clicked on original app Icon"

    But I m not getting how to detect when the user will click on the updated Icon ?
    Last edited by Shreyas; 11-11-09 at 11:57 PM.
    11-11-09 11:19 PM
  9. QuiteSimple's Avatar
    Hm, ok, you can try a different approach

    Make a dummy first screen, which will be empty, you will use it to open Screen1 or Screen2.

    Overwrite the screen.onExposed() method and place the showGui() code inside. onExposed() method is called when the screen comes in foreground.
    So when your dummy screen is called via the main method, it will open Screen1 or Screen2 depending on the constant used. After calling Screen 1/2 just close the dummy screen, so it won't be visible in the stack.

    Well, it is just an idea, I didn't try it by myself
    11-12-09 05:50 AM
  10. Shreyas's Avatar
    I made the Alternale Entry point & Main CLDC app like this article below,


    How To - Setup an alternate entry point for my application


    I have got an article as,

    How to - Make a running UI application go to the background and resume in the foreground

    in which its said that

    The alternate entry is going to call the main method with the parameter that is passed in, regardless of whether the application is running.


    But in my case the main() is not getting called when I click on appIcon when the app is running in background.

    It only updates appIcon & appName which is previously set in Alternate Entry Point.

    So I m not getting where the control goes if its not calling main() when clicked on updatedIcon?

    Is anyone has any idea on this issue?
    11-13-09 01:19 AM
  11. Shreyas's Avatar
    Hey QuiteSimple,

    I got the result with overriding onExposed().

    Thanks a lot..
    11-13-09 03:55 AM
  12. Shreyas's Avatar
    Now I m searching for how to read System Profiles like if I set "Vibrate only" in my Menu->Profiles then the device should Vibrate only using Alert.startVibrate() or Alert.startAudio etc...

    any idea on this?
    11-13-09 11:32 PM
  13. Shreyas's Avatar
    About onExposed()....

    I gave a condition & if its met then only call onExposed() but even though that condition is not met then also onExposed() is getting called.

    Whenever a screen is displayed then everytime onExposed() is being called irrespective of any condition ?
    11-14-09 08:42 AM
  14. QuiteSimple's Avatar
    Hi,

    onExposed() is called every time when a screen comes to the foreground. It is part of the screen life cycle, so you can't skip it, you can just skip the code execution inside the onExposed()

    As for your previous question about the profiles - maybe I'm wrong, but as far as I remember you cannot retrieve the current Profile, you can only set a Profile. By the way, take a look at the "notification" demo in the JDE samples (with every JDE there are few sample applications shipped), in this demo you can find good ideas how to integrate with the Profiles.
    11-14-09 12:52 PM
  15. Shreyas's Avatar
    Ok. Thanks for both the answers...
    11-15-09 10:58 PM
LINK TO POST COPIED TO CLIPBOARD