02-18-2011 08:15 AM
In my apps construtor and on other places i use the following code to update the applications icon and set a
rollover icon.
public static void changeHomeScreenIcon(boolean unreadItems) {
if (unreadItems) {
HomeScreen.updateIcon(BitmapProvider.START_STAR, 0);
HomeScreen.setRolloverIcon(BitmapProvider.START_ST AR_MO, 0);
} else {
HomeScreen.updateIcon(BitmapProvider.START, 0);
HomeScreen.setRolloverIcon(BitmapProvider.START_MO , 0);
}
}
On startup (app is an autostart app) i get an illegal argument exception.
When I use the same method while the software is running everything works fine.
Any ideas?
:
02-18-2011 08:43 AM
Are you checking ApplicationManager.getApplicationManager.inStartup
I'm not sure you can do that waiting right there in the constructor code, but if you start an initialization Thread and do all the necessary things there, you can certainly loop and wait for that flag to become false before doing anything else.
02-18-2011 08:46 AM - edited 02-18-2011 08:53 AM
AFAIR,
invokeLater(new Runnable() {
public void run() {
net.rim.blackberry.api.homescreen.HomeScreen.updat eIcon(icon);
}
});
solved problem with this exception for me, so you can try it too, however, I do not call it when inStartup. When in startup, you can just register your app as a SystemListener and do initialization in powerUp method implementation.
02-18-2011 08:56 AM
yes, i check the startup with this code
while (app.inStartup()) {
try {
Thread.sleep(400);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
(i am aware of the "register a listener"-approach but didn't think it necessary to change this).
@Orzech: I cannot use invokelater in a static context.
if i am not able to solve the problem i may be able to refactor it this way.
In fact, on a real device, it is not a problem, it occurs only on the simulator (forgot to mention this on the first post), if i click "continue" 4 times in the debugger everything works correctly (but the rollover icon is only set on a later call, of course).
02-18-2011 08:58 AM
Hi Simon,
Me too updating my application icon and it is static function. I did not face such issue on any OS version. Are you facing this issue on all OS versions?
Note, I was getting error "module with handle[] and index[] has no entry point" when attempt made to updateIcon while device boot. (I am not sure whether you are having requirement to update app icon at the device boot up). I just fixed up by trying N attempts with delay temporarily.
Thanks!
02-18-2011 09:01 AM - edited 02-18-2011 09:04 AM
Sorry, I thought it is possible to call Application.getApplication().invokeLater in a static context (shame on me, because one needs to have application's instance created to make this working, obviously). SystemListener approach works perfectly for me on both device and simulator, so unfortunately nothing more comes to my mind at this moment. Good luck!
Regards,
Piotr
02-18-2011 09:10 AM
I have moved the startup code into a static context, get the same error now only with the dispatchinvokelater in front.
notable is that i see this error only when hot-swapping the simulator (i should know better than not to include all info in the first post, but was on a (boring) conf call...)
according to the docs an illegal argument exception means that the entry point is not found. it's just strange that it works some time later. maybe it is an unsolvable sideeffect of the hot swap.