Application Icons
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 the following:
-
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, follow these steps:
-
To handle badges, follow the steps below:
-
To use the Tizen.Applications.Badge class, the application has to request permission by adding the following privilege to the
tizen-manifest.xml
file:XMLCopy<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:
C#Copyusing Tizen.Applications.Badge;
-
-
To handle shortcuts, follow the steps below:
-
To use the Tizen.Applications.Shortcut namespace, the application has to request permission by adding the following privilege to the
tizen-manifest.xml
file:XMLCopy<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:
C#Copyusing Tizen.Application.Shortcut;
-
Create and remove a badge
To create and remove badges, follow these steps:
-
To create a badge for an application, create an instance of the Tizen.Applications.Badge 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:
C#CopyBadge 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 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:C#CopyBadgeControl.Remove(TEST_PKG);
Manage the badge
To manage the badge, follow these steps:
-
Retrieve the badge count and visibility with the
Find()
method of the Tizen.Applications.BadgeControl class. The values are stored in thecount
andvisible
properties of the Tizen.Applications.Badge 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:C#Copyuint count; bool visible; Badge badge = BadgeControl.Find(TEST_PKG); count = badge.Count; visible = badge.Visible;
-
Set the
count
andvisible
properties with theUpdate()
method:C#CopyBadge badge = new Badge(TEST_PKG); BadgeControl.Add(badge); badge.Count = 5; badge.Visible = false; BadgeControl.Update(badge);
Add a shortcut
To add a shortcut to the home screen, follow these steps:
-
Define the shortcut details (such as its name, icon path, and whether duplicates are allowed) with the properties of the Tizen.Applications.Shortcut.HomeShortcutInfo class.
You can create 2 types of shortcuts, they are:
- 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:
C#CopyHomeShortcutInfo 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 class:C#CopyShortcutManager.Add(shortcut);
Add a widget
To add a widget to the home screen, follow these steps:
-
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 class:
C#CopyWidgetShortcutInfo 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 class:C#CopyShortcutManager.Add(shortcut);
Related information
- Dependencies
- Tizen 4.0 and Higher