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
New Developer
aleksandr
Posts: 20
Registered: ‎08-11-2008
My Device: Not Specified

icons from getVisibleApplications look odd

i'm trying to implement a "switch application" menu using getVisibleApplications to get the ApplicationDescriptor and from that appdescriptor.getIcon(). However, the icons it returns do not match the "real" application icon. Some are only B+W.

 

Some articles have sugguested that this is all getIcon can do but I have seen "switch application" commands in other 3rd party applications and the icons look fine there.

 

Is there another API that I should look at to get the correct icons? Is there a build in command to handle the entire switch application command (i know about alt-esc, but I would like a menu item).

 

Thanks. 

Developer
RexDoug
Posts: 4,764
Registered: ‎07-21-2008
My Device: Not Specified

Re: icons from getVisibleApplications look odd

I have a similar development task, and I agree that the icons are not identical to the images on the home screen or the ribbon. For example, the mail icon is a black & white line drawing of an envelope.

 

So, doing more research I switched to CodeModuleManager, using getHandle() and getApplicationDescriptor() to retrieve the icon from this direction.

 

Using this method, the icons are either B&W line drawings, or they come back from getIcon() as "null".

 

Developer
myraddin
Posts: 412
Registered: ‎09-12-2008
My Device: 9000 9810

Re: icons from getVisibleApplications look odd


So is there a way to get a 'normal' application icons in any way ?

 

I use CodeModuleManager.getApplicationDescriptors(int handle) + getIcon() and almost all of the applications (with few notable exceptions) are black & white edge drawings.

 

Can someone confirm that it is impossible to get a full resolution, colored application icon (for instance: "address book" a.k.a "contacts") ? 

 

Since we cannot access theme data, are we left stranded in drawing a non-theme look & feel  :smileysad: ?

Too bad for the users of our applications.



"Listen carefully, I shall say this only once"
Developer
adwiv
Posts: 304
Registered: ‎08-01-2008
My Device: Not Specified

Re: icons from getVisibleApplications look odd

The actual icons you see on the device for native applications come from the theme and not from the code module.

 

The icons you are getting are the B/W icons that date back to the time when there were no themes and BB could only support monochrome.

 

I have not tried this yet, but you should be able to get the icons from the current theme cod module. You can get the name of the active theme from the HomeScreen class, and then get the icon from the theme mdoule.

Developer
myraddin
Posts: 412
Registered: ‎09-12-2008
My Device: 9000 9810

Re: icons from getVisibleApplications look odd

Yes, I noticed something that also leads to this conclusion...

Only a few of the 'native' applications' icons are not b/w (namely messenger, LBS ...) And all other 'native' applications are b/w.

On the other hand, all non-native applications expose their icen as they should.

 

Thank you for the tip about the themes, but do you have any code snippet we could use for such purpose ?

 

How do you suggest to access that cod module ?



"Listen carefully, I shall say this only once"
Developer
adwiv
Posts: 304
Registered: ‎08-01-2008
My Device: Not Specified

Re: icons from getVisibleApplications look odd

Accessing cod module should be simple - Bitmap.getBitmapResource(String module, String name);

 

All you need is the name of the bitmap file as stored in the theme.

 

Some preliminary tests show the following nomenclature:

1. Take the name of the native module whose image you want (eg net_rim_bb_messaging_app)

2. Add the name of the arguments to the specific entry point (For example, the arguments for AppDesciptor of main messages app is "Messages") You can list out the application descriptors of a module using CodeModuleManager. Of course you would be interested only in the appdescriptors that do not have the  "System" flag set. If the arguments is null, leave out this step.

3. If you want the focus icon, add "~focus".

4. Add png

 

So the resource name for default messags icon should be "net_rim_bb_messaging_app.Messages.png" and the focus icon should be "net_rim_bb_messaging_app.Messages~focus.png"

 

On a storm simulator the following code seems to work:

 

 

Bitmap bmp = Bitmap.getBitmapResource("net_rim_theme_precision_zen_360x480_t", "net_rim_bb_messaging_app.Messages~focus.png");

 


 

Developer
myraddin
Posts: 412
Registered: ‎09-12-2008
My Device: 9000 9810

Re: icons from getVisibleApplications look odd

Hmm... very intriguing finding.

 

But...

 

First of all, I don't see whay the 'system' flag is of any importance... but, ok, this limitation does not bother me.

1) Secondly, how did you came about the second ('name') parameter of the getBitmapResource(String, String) method ?

 

2) Shouldn't theme's .cod contain all the icons that theme uses ?

 

3) To be more specific, how did you devise this construction: ".Messages~focus.png" ?

 

Thanks for providing another very interesting insight on this subject.

 

 



"Listen carefully, I shall say this only once"
Developer
adwiv
Posts: 304
Registered: ‎08-01-2008
My Device: Not Specified

Re: icons from getVisibleApplications look odd

Does it work? I haven't tried it myself, I remembered it vaguely from pre 4.0 days when I was trying to make my application have a different rollover icon and the API didn't support it.

 

Also, to find this and a lot of other intriguing stuff all you need is:

 

1. The JDE Profiler tool

 

2. A lot of free time :smileyhappy:

New Developer
Kalamity
Posts: 7
Registered: ‎01-14-2009
My Device: Not Specified

Re: icons from getVisibleApplications look odd

[ Edited ]

Cool Thanks! It works. However I noticed you need to parse out the name from the application theme, otherwise you will get the full path (e.g java:/net.rim.devie.internal.ui.theme.ThemeFactory?ext=net_rim_theme_precision_zen_360x480_t) Other than that it seems to work just fine! :smileyhappy:

 

I do have another issue as well, the mail icon shows up but I haven't got any other applications to work properly running the debugger I get 

 

FRIDG: could not find net_rim_bb_phone_app.Phone.png

FRIDG: could not find net_rim_bb_browser_daemon.Browser.png 


Is there something that I am missing?