zoukankan      html  css  js  c++  java
  • 如何获取应用程序图标(转)

    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
    ...
    }

    References How to get Application Icon using RApaLsSession

    How to get Application Icon using RApaLsSession

    #include <APGCLI.H>
    Link against: apgrfx.lib
    RApaLsSession aLs;
    User::LeaveIfError(aLs.Connect());
    CleanupClosePushL(aLs);
    CArrayFixFlat<TSize>* array=new(ELeave)CArrayFixFlat<TSize>(3);
    CleanupStack::PushL(array);
    User::LeaveIfError(aLs.GetAppIconSizes(uid,*array));
    for(TInt i=0;i < array->Count();i++)
    {
    CApaMaskedBitmap* iconBySize=CApaMaskedBitmap::NewLC();
    if(aLs.GetAppIcon(KUidTestApp,(*array)[i],*iconBySize) == KErrNone)
    //icon is now in iconBySize
    CleanupStack::PopAndDestroy(iconBySize);
    }
    CleanupStack::PopAndDestroy(array);
    CleanupStack::PopAndDestroy(&aLs);
  • 相关阅读:
    socket的accept函数解析
    c socket(续)
    C socket指南
    网络字节序和本机字节序
    jar包
    RESTful API 设计指南[转]
    理解RESTful架构[转]
    c语言正则表达式
    Fedora设置中文
    创建框架结构的页面2
  • 原文地址:https://www.cnblogs.com/yaoliang11/p/2065975.html
Copyright © 2011-2022 走看看