views:

50

answers:

0

I'm trying to dynamically set a different icon based on device. I have set up an alternate entry point within the app's descriptor XML file. It passes an argument of "icon" into main() of my application.

The entry point is triggered as expected (installing the app and on power cycle), but it has issues when calling updateIcon() on certain phones (e.g. BB 8900 T-Mobile version 4.6.1.231 (Platform 4.2.0.108)). Looks like it fails on phones below OS 4.7 and works fine on phones on or above that level.

The error I am getting is IllegalArgumentException: "Module with handle [XXXX] and index [X] has no application entry point". Trying to set the index to both 0 and 1 on updateIcon() has the same issue.

This is only occuring when I install the app OTA (cable loading works on the 8900).

I based my code below on the KB article regarding this matter:

public static void main(String[] args) {
    if ( args != null && args.length > 0 && args[0].equals("icon") ){
        MyApp instance = new MyApp(true);
    } else {
        MyApp instance = my MyApp(false);
    }
    instance.enterEventDispatcher();
}

public MyApp(boolean autostart){
    if(autostart){
        Bitmap loadedIcon;
        int width = HomeScreen.getPreferredIconWidth();
        int height = HomeScreen.getPreferredIconHeight();

        //conditional logic to initialize "loadedIcon" based on device icon width

        final Bitmap icon = loadedIcon;
        invokeLater(new Runnable(){
                  public void run(){
                      ApplicationManager myAppManager = ApplicationManager.getApplicationManager();
                      boolean keepGoing = true;
                      while (keepGoing){
                          //Check if the BlackBerry has completed its startup process.
                          if (myAppManager.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.
                              try {
                                  HomeScreen.updateIcon(icon, 0);
                                  HomeScreen.setRolloverIcon(icon, 0);
                              } catch(Exception e){
                                  System.out.println("setting icon caught: " + e.getMessage());
                                  e.printStackTrace();
                          }
                          keepGoing = false;
                      }
                  }
                  //Exit the application.
                  System.exit(0);
              }
          });
} else {
    //load the app normally, with UI.
}
}

I am using Eclipse Plug-in 1.1.2 to build my app, but the article is targeting the older, deprecated 1.0 plugin, maybe the instructions don't apply anymore and should be updated? Would following that KB article in the same manner using the new plug-in result in setting the entry points properly?