Update the application icon on the BlackBerry via a Java program, with a number on the icon

Source: Internet
Author: User
Tags add numbers

The following code allows you to change the program icon

Bitmap Icon=bitmap.getbitmapresource ("Icon/unread.gif");
Net.rim.blackberry.api.homescreen.HomeScreen.updateIcon (icon,1);

But it's not cool enough to add numbers to the icons. Numbers are used to indicate how many are to be done, or how much the temperature is.

To improve the code above:

Bitmap Icon=bitmap.getbitmapresource ("Icon/unread.gif");
Bitmap Icon1 = Getupdateiconbitmap (icon, count);
Net.rim.blackberry.api.homescreen.HomeScreen.updateIcon (icon1,1);

Private Bitmap Getupdateiconbitmap (Bitmap bmp, int count) {
int width = bmp.getwidth ();
int height = bmp.getheight ();
Bitmap iconbmp = new Bitmap (width, height);
Graphics g = new Graphics (iconbmp);
Xyrect rect = new Xyrect (0, 0, width, height);
G.drawbitmap (rect, BMP, 0, 0);

G.setfont (G.getfont (). Derive (Font.Bold, UI.UNITS_PX,
Font.antialias_standard, Font.colored_outline_effect));

String Text = integer.tostring (count);
G.setcolor (color.red);
G.drawtext (text, 0, 0);

return iconbmp;
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.