Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Developer
Posts: 27
Registered: ‎07-17-2008
My Device: Not Specified
Accepted Solution

Setting a rollover icon

I have set up a test application to try and set a rollover icon and have followed the advice in the following Knowledge Base articles

 

and also in this thread http://supportforums.blackberry.com/rim/board/message?board.id=java_dev&thread.id=3623

 

I have set the index as per the above thread in the following API calls:

HomeScreen.updateIcon( regIcon, 1 );
HomeScreen.setRolloverIcon( icon, 1 );

I have installed the same sample application on a 8100 device and a 8310 device.  The 8100 device works perfectly, but the 8310 device throws a "Module with handle [handleID] and index [index] has no application entry point" error message.

 

Does anybody know why this would work on one device, but not another?  Is there any way to resolve this?

BlackBerry Development Advisor
Posts: 15,723
Registered: ‎07-09-2008
My Device: BlackBerry PRIV
My Carrier: Bell

Re: Setting a rollover icon

What are the versions of BlackBerry handheld software you are testing on?  You can find this under Options, About on the BlackBerry.
Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
Developer
Posts: 27
Registered: ‎07-17-2008
My Device: Not Specified

Re: Setting a rollover icon

[ Edited ]

The 8100 device is running 4.2.0.67 and the 8310 is running 4.2.2.146.

 

And incidentally, I tested both devices with an over the air installation last night and no error was thrown on either device and both rollover icons work.

 

Installing the app via the Desktop Manager still throws the error on the 8310 device though.

Message Edited by spookendiesel on 10-01-2008 03:25 PM
BlackBerry Development Advisor
Posts: 15,723
Registered: ‎07-09-2008
My Device: BlackBerry PRIV
My Carrier: Bell

Re: Setting a rollover icon

There is a race condition that can be occuring in this version.  The work around is to wrap the updateIcon and setRolloverIcon methods within an invokeLater block.  You can see an example in the link below, however note that in this case you should omit the "UiApplication.getUiApplication()." call that prefixes the invoekLater.

 

How to - Update a screen on the Main Event Thread
Article Number: DB-00136

http://www.blackberry.com/knowledgecenterpublic/livelink.exe/fetch/2000/348583/800332/800505/800256/...

 

This should place the update in the applications event queue and get processed in the correct order.

Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
Developer
Posts: 27
Registered: ‎07-17-2008
My Device: Not Specified

Re: Setting a rollover icon

Hmm, my code already has an invokeLater block (as per the article http://www.blackberry.com/knowledgecenterpublic/livelink.exe/fetch/2000/348583/800332/800505/800608/...).  Here is the main class for my RolloverTest app:

/* * RolloverTest.java * * © <your company here>, 2003-2005 * Confidential and proprietary. */ package rollovertest; import net.rim.blackberry.api.homescreen.HomeScreen; import net.rim.device.api.system.ApplicationManager; import net.rim.device.api.system.Bitmap; import net.rim.device.api.ui.UiApplication; /** * */ class RolloverTest 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")) { RolloverTest theApp = new RolloverTest(false); theApp.enterEventDispatcher(); } else { RolloverTest theApp = new RolloverTest(true); theApp.enterEventDispatcher(); } } public RolloverTest(boolean autoStart) { if (autoStart) { //The application started using the auto start entry point. //Setup the rollover icons. final Bitmap regIcon = Bitmap.getBitmapResource("mobicon_36x36.png"); final Bitmap icon = Bitmap.getBitmapResource("mobicon_36x36_highlight.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, 1); HomeScreen.setRolloverIcon(icon, 1); keepGoing = false; } } //Exit the application. System.exit(0); } }); } else { //The application was started by the user. //Start the application and display a GUI. pushScreen(new ScrTest()); } } }

Putting a second invokeLater block around the updateIcon and setRolloverIcon methods stops the error being thrown, but the rollover icon still does not work.

BlackBerry Development Advisor
Posts: 15,723
Registered: ‎07-09-2008
My Device: BlackBerry PRIV
My Carrier: Bell

Re: Setting a rollover icon

Have you tried using 0 as the entry point?  The icon needs to be updated for the non system project.
Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
Developer
Posts: 27
Registered: ‎07-17-2008
My Device: Not Specified

Re: Setting a rollover icon

Yes, I have tried 0 - which throws an error on the simulator and on the other device.  The index of 1 ensures the rollover icon works on both the simulator and the other device, but not on the 8310.  It is the same build of code which I am installing on the 2 devices.
BlackBerry Development Advisor
Posts: 15,723
Registered: ‎07-09-2008
My Device: BlackBerry PRIV
My Carrier: Bell

Re: Setting a rollover icon

Has your carrier release version 4.5.0 for the BlackBerry 8310?  It should be found on their web site of it was.  If it is available can you upgrade and see if the problem remains?

Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
Highlighted
Developer
Posts: 27
Registered: ‎07-17-2008
My Device: Not Specified

Re: Setting a rollover icon

[ Edited ]

public RolloverTest(boolean autoStart) { if (autoStart) { //The application started using the auto start entry point. //Setup the rollover icons. final Bitmap regIcon = Bitmap.getBitmapResource("mobicon_36x36.png"); final Bitmap icon = Bitmap.getBitmapResource("mobicon_36x36_highlight.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 { try { //The BlackBerry has finished its startup process. //Set the rollover icons. HomeScreen.updateIcon(regIcon, 1); HomeScreen.setRolloverIcon(icon, 1); keepGoing = false; } catch (Exception ex) { // Couldn't set the rollover icon, handle exception } } } //Exit the application. System.exit(0); } }); } else { //The application was started by the user. //Start the application and display a GUI. pushScreen(new ScrTest()); } }

 

I have been playing around with this code sample a little bit more and added a try/catch statement (highlighted in red in the above example) around the code to set the rollover icon.  The rollover icon now works every time and I no longer see the error message.  Hurrah! Smiley Very Happy

Message Edited by spookendiesel on 10-07-2008 02:28 PM
New Developer
Posts: 3
Registered: ‎03-17-2009
My Device: Not Specified

Re: Setting a rollover icon

[ Edited ]

Hi,

 

I have same problem. I'm using JDE 4.2.1 Eclipse Plug-in.

 

My Code is:

 

 

public GameMIDletApp(boolean autostart)
{
int width, height;

if (autostart) {
width = HomeScreen.getPreferredIconWidth();
height = HomeScreen.getPreferredIconHeight();

final Bitmap icon = Bitmap.getBitmapResource("res/icon" + width + "x" + height + ".png");

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

while(keepGoing)
{
//Check if the BlackBerry has completed its startup process.
if (am.inStartup())
{
try { Thread.sleep(1000); } catch(Exception e) {}
} else
{
//Update Icon
try
{

HomeScreen.updateIcon(icon, 1);
HomeScreen.setRolloverIcon(icon, 1);
}catch(Exception e)
{
// Couldn't set the rollover icon, handle
}


//Exit Loop
keepGoing = false;
}
}
//Exit App
System.exit(0);
}
});
} else {
//Create Screen
ge = new GameEngine(this);
//Push Screen to get sizes
pushScreen(ge);

}
}

 

If i remove the "red try-catch block" the simulator always throw IllegalArgumentException (with entry point 0 too). If i execute the app with the try-catch blockthe app doesn't show in the simulator, the icons doesn't appears!! Smiley Frustrated

What can i do? I don't know how fix it. Any idea? help!

 

Thanks

 

 

Message Edited by Morpheo17 on 03-18-2009 06:43 AM