How to get preferred size of HomeScreen icon?

here is the answer[1]:

int height = net.rim.blackberry.api.homescreen.HomeScreen.getPreferredIconHeight();
int width = net.rim.blackberry.api.homescreen.HomeScreen.getPreferredIconWidth();

then update the icon:

net.rim.blackberry.api.homescreen.HomeScreen.updateIcon( icon );

here is the icon size from Ui guidelines[3].

How to create Roll over Icon[2]:

  • for BB OS before 4.7*
public class HomeScreenIcon extends UiApplication
{
    public static void main(String[] args)
    {
        //Check for the argument defined in the project properties.
        if (args != null && args.length > 0 && args[0].equals("gui"))
        {
           HomeScreenIcon theApp = new HomeScreenIcon(false);
            theApp.enterEventDispatcher();
        }
        else
        {
            HomeScreenIcon theApp = new HomeScreenIcon(true);
            theApp.enterEventDispatcher();
        }
    }
    public HomeScreenIcon(boolean autoStart)
    {
        if (autoStart)
        {
        //The application started using the auto start entry point.
        //Setup the rollover icons.
        final Bitmap regIcon = Bitmap.getBitmapResource("1.png");
        final Bitmap icon = Bitmap.getBitmapResource("2.png");

        invokeLater(new Runnable()
        {
            public void run()
            {
                ApplicationManager myApp =
                  ApplicationManager.getApplicationManager();
                boolean keepGoing = true;

                while (keepGoing)
                {
                    //Check if the BlackBerry has completed its
                        startup process.
                    if (myApp.inStartup())
                    {
                        //The BlackBerry is still starting up,
                             sleep for 1 second.
                        try
                        {
                            Thread.sleep(1000);
                        }
                        catch (Exception ex)
                        {
                          //Couldn't sleep, handle exception.
                        }
                    }
                    else
                    {
                        //The BlackBerry has finished its
                             startup process.
                        //Set the rollover icons.
                        HomeScreen.updateIcon(regIcon, 0);
                        HomeScreen.setRolloverIcon(icon, 0);
                        keepGoing = false;
                    }
                 }
                 //Exit the application.
                 System.exit(0);
            }
        });

    }
    else
    {
         //The application was started by the user.
         //Start the application and display a GUI.
         MainScreen ms = new MainScreen();
         ms.setTitle(new LabelField("Hello there."));
         pushScreen(ms);
    }
  }
}

[1] http://supportforums.blackberry.com/rim/board/message?board.id=java_dev&message.id=1484
[2] http://www.blackberry.com/knowledgecenterpublic/livelink.exe/fetch/2000/348583/800332/800505/800608/How_To_-_Define_a_rollover_icon_for_an_application.html?nodeid=1162799&vernum=0
[3] http://na.blackberry.com/eng/deliverables/6625/Dimensions_for_screens_images_and_icons_476251_11.jsp