• 如何获取应用程序图标(转)


    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);
  • 相关阅读:
    MySQL约束笔记
    MySQL 存储过程入门
    数据库范式
    Hibernate 懒加载 错误----no session
    复选框 checkbox 选中事件
    Hibernate 三种状态变化 与 sql 语句的关系
    Spring 4 + Hibernate 4 下 getCurrentSession()的使用情况
    35个java代码性能优化总结
    为什么 Java中1000==1000为false而100==100为true?AND "2+2=5"?
    MyBatis对象关联关系----多对多的保存与查询
  • 原文地址:https://www.cnblogs.com/yaoliang11/p/2065975.html
Copyright © 2020-2023  润新知