Application Icons
PUBLISHED
You can show the application icon as a shortcut on the home screen to allow the user to easily launch the application. In the device application list, you can show a badge with the application icon to provide additional information about the application state or notifications to the user.
The main application icon features include:
- Creating and removing a badge
You can use badges in your application to inform the user about notifications and events. A badge is an image displayed on the application icon.
You can create a badge for an application and remove it.
- Managing the badge
You can get and set the count and display attributes for the badge.
- Adding a shortcut
You can add a shortcut to the home screen to launch an application.
- Adding a widget
If you have created a widget application, you can add the widget to the home screen.
Figure: Badges and shortcuts
Prerequisites
To enable your application to use the application icon functionality:
- To handle badges:
-
To use the Tizen.Applications.Badge [1] class, the application has to request permission by adding the following privilege to the
tizen-manifest.xml
file:<privileges> <privilege>http://tizen.org/privilege/notification</privilege> </privileges>
-
To use the methods and properties of the Tizen.Applications.Badge class, include it in your application:
using Tizen.Applications.Badge;
-
- To handle shortcuts:
- To use the Tizen.Applications.Shortcut [2] namespace, the application has to request permission by adding the following privilege to the
tizen-manifest.xml
file:<privileges> <privilege>http://tizen.org/privilege/shortcut</privilege> </privileges>
- To use the methods and properties of the Tizen.Applications.Shortcut namespace, include it in your application:
using Tizen.Application.Shortcut;
- To use the Tizen.Applications.Shortcut [2] namespace, the application has to request permission by adding the following privilege to the
Creating and Removing a Badge
To create and remove badges:
-
To create a badge for an application, create an instance of the Tizen.Applications.Badge [1] class. The parameter defines the application for which the badge is added. If the application is adding a badge for itself, the parameter can be null.
Badge badge = new Badge(appId); BadgeControl.Add(badge);
The application that creates the badge can also update and remove it. When applications are signed with the same certificate, they can control each other's badges.
If an application not signed with the same certificate must be allowed to manage a badge, use the
Add()
method of the Tizen.Applications.BadgeControl [3] class with a writable application ID. The writable application ID enables another application to control your application to manage the badge. You can also configure your application to handle the badge itself. -
To remove the badge from the application, call the
Remove()
method. The only parameter is the ID of the application whose badge is to be removed.BadgeControl.Remove(TEST_PKG);
Managing the Badge
To manage the badge:
- Retrieve the badge count and visibility with the
Find()
method of the Tizen.Applications.BadgeControl [3] class. The values are stored in thecount
andvisible
properties of the Tizen.Applications.Badge [1] class.The badge count is displayed in the upper-right corner of the badge and the
count
property value must be an integer. Thevisible
property value is of theBool
type.uint count; bool visible; Badge badge = BadgeControl.Find(TEST_PKG); count = badge.Count; visible = badge.Visible;
- Set the
count
andvisible
properties with theUpdate()
method:
Badge badge = new Badge(TEST_PKG); BadgeControl.Add(badge); badge.Count = 5; badge.Visible = false; BadgeControl.Update(badge);
Adding a Shortcut
To add a shortcut to the home screen:
- Define the shortcut details (such as its name, icon path, and whether duplicates are allowed) with the properties of the Tizen.Applications.Shortcut.HomeShortcutInfo [4] class.
You can create 2 types of shortcuts:
- If you set the
Uri
property, clicking the shortcut opens the URI. - If the
Uri
property is not set, clicking the shortcut launches the application that set the shortcut.
HomeShortcutInfo shortcut = new HomeShortcutInfo { ShortcutName = "Home", IconPath = "Icon_Path", IsAllowDuplicate = true, Uri = "http://www.tizen.org" };
- If you set the
- Add the shortcut using the
Add()
method of the Tizen.Applications.Shortcut.ShortcutManager [5] class:
ShortcutManager.Add(shortcut);
Adding a Widget
To add a widget to the home screen:
- Before adding a widget to the home screen, a widget application must be prepared.
- Define the widget details (such as its ID, size, and period) with the properties of the Tizen.Applications.Shortcut.WidgetShortcutInfo [6] class:
WidgetShortcutInfo shortcut = new WidgetShortcutInfo { shortcutname = "samplewidget", iconpath = "icon_path", isallowduplicate = false, widgetid = "widgetid", widgetsize = shortcutwidgetsize.widgetdefault, period = 1.0f };
To add a widget, you must know the widget ID and supported sizes.
- Add the widget using the
Add()
method of the Tizen.Applications.Shortcut.ShortcutManager [5] class:
ShortcutManager.Add(shortcut);