views:

223

answers:

6

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?

A: 

Not sure but maybe you talking about focused icon when user touch it?
In this case try setRolloverIcon

public static final void setRolloverIcon(Bitmap rollovericon)
Sets the rollover icon for use with this application. If rollovericon is null, then the application's default rollover icon, as specified in the original project workspace, is used.
Note: If you have not specified a main application icon for the application, you must call updateIcon and provide an icon before setting the rollover icon. Otherwise, the system will override the main icon and the rollover icon as set by this method with the default icons for the current theme.
Note: Changes made using this API are NOT persisted across resets.
Parameters:
rollovericon - Icon to use when the application icon is in focus on the home screen, or null if the application's default rollover icon is to be used.
Since: JDE 4.1.0
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.

Max Gontar
A: 

I m updating the app. icon if a particular condition is met & not changing it when user touches it. Now if I go back to Main Menu then the app icon is updated & when I click on it I want to display a particular screen like I was doing in main() when I click on old app icon as,

public static void main (String[] args)
{      
      Screen1 scr1 = new Screen1()
      pushScreen(scr1);
}

Now after clicking on updated app. icon I want to display "Screen2" instead of "Screen1".

I tried using setRolloverIcon() after HomeSceeen.updateIcon() but how to handle clicking on it ?

Shreyas
A: 

I'm also not sure, i think its not an issue with your application icon, what I understood is like you are changing application icon at some point when application was in background, which should work fine with out an issue. Next you want when the icon has been changed (meaning application is in some other state now) so if user clicks on the application icon you want to show some other screen (lets say Screen2) not the first one (lets say Screen1) which you would normally display?

If my understanding is correct, may be following could be helpful. 1. If your application always run in the background, you might want to manage your application state related information in RuntimeStore. Use RuntimeStore to store the state info when you changed application icon as per your business logic, then when user clicks on the application icon at Home screen, you can check the state info in RuntimeStore and do the needful. 2. If your application do not always run in background, you can apply the above #1 logic using PersistentStore instead of RuntimeStore.

I hope it would help.

Thanks, Sameer Nafdey.

Sameer Nafdey
A: 

Hi Sameer,

u r correct.

now I m setting an int var. in RuntimeStore when updates app. icon like,

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,

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();
}
Shreyas
A: 

I updated the appIcon, appName & storing the state of appIcon in RuntimeStore.

Now 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 should go through main() when clicked on original app Icon".

I was thinking when I click on updated appIcon the control will go to main() but instead of calling main() it says,

         Starting AppName
         AppName already running

& directly it goes to first screen. and when I come back to Main Menu the app has updated icon & name

So how to get original appIcon & appName ?

Shreyas
A: 

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?

Shreyas
I got the result for my previous post. 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?
Shreyas