Get application icon using Symbian C++
Article Metadata
Following code sample can be used to retrieve application icons
Hearders Required:
#include <fbs.h> //CFbsBitmap
#include <aknsskininstance.h> //MAknsSkinInstance
#include <aknsutils.h> //AknsUtils
Library required:
LIBRARY fbscli.lib ///CFbsBitmap
LIBRARY aknskins.lib aknskinsrv.lib aknswallpaperutils.lib //MAknsSkinInstance ,AknsUtils
Source Code:
CGulIcon* CMyClass::GetApplicationIconL(const TUid& aAppUID)
{
CFbsBitmap* AppIcon(NULL);
CFbsBitmap* AppIconMsk(NULL);
MAknsSkinInstance* skin = AknsUtils::SkinInstance();
AknsUtils::CreateAppIconLC(skin,aAppUID, EAknsAppIconTypeContext,AppIcon,AppIconMsk);
CleanupStack::Pop(2);
return CGulIcon::NewL(AppIcon,AppIconMsk);
}
You could get application UIDs from TApaAppInfo, which you could get for example by using the code sample shown in here
A known issue:
The utility function doesn't need any capability if you are creating app icons of Symbian OS C++ applications. But when getting the app icons of Java applications the AllFiles capability is required. As it is less possible for a normal application to have AllFiles capability, it is suggested to add error handling code like this:
// first try to use the utility function
TRAPD(err, AknsUtils::CreateAppIconL(...))
if(err!=KErrNone)
{
// if it failed then use the traditional way
err = RApaLsSession::GetAppIcon();
}
if(err!=KErrNone)
{
// if both of them failed then
// load a default icon for the application
...
}


28 Sep
2009
Normally one application need not to access application icon of other application. But in some case one application may need to access application icon of other application, for example when application is maintaining list of installed application in device.
This article demonstrates how to get application icon based on application UID. It illustrates how to use API AknsUtils::CreateAppIconLC() to get application icon. Article also describes that application needs AllFiles capability to access application icon of Java applications, So be aware of this issue (as getting AllFiles capability is very hard) before using it for java applications.