symbian 安装启动第三方程序

个人整理原创,如要转载,请注明去处!以下无特殊说明,都是针对symbian第三版。

1)安装第三方程序:

void CFunctions::InstallJarFileL(const TDesC& aFilePath)
    {
    RApaLsSession apaSession;
    User::LeaveIfError(apaSession.Connect());
    TDataType dataType(_L8("text/vnd.sun.j2me.app-descriptor")); //jar

  //TDataType dataType(_L8("application/vnd.symbian.install"));//sis
    TThreadId threadID2;
    apaSession.StartDocument(aFilePath, dataType, threadID2);
    apaSession.Close();
    }

 

2)启动第三方程序

void CFunctions::RunAppL(const TDesC& appPath)
    {
    CApaCommandLine *cmd = CApaCommandLine::NewLC();
    cmd->SetCommandL(EApaCommandRun);
    cmd->SetExecutableNameL(appPath);
    RApaLsSession als;
    User::LeaveIfError(als.Connect());
    CleanupClosePushL(als);
    User::LeaveIfError(als.StartApp(*cmd));
    CleanupStack::PopAndDestroy(2);
    }

 

//查找并启动第三方程序

void CFunctions::FindRunAppL(const TDesC& appName)
    {
    CAknInformationNote* informationNote;
    informationNote = new ( ELeave ) CAknInformationNote;

    RApaLsSession appSession;
    if (appSession.Connect() == KErrNone && appSession.GetAllApps() == KErrNone)
        {
        TApaAppInfo appInfo;
        TInt result = KErrNone;
        TInt handeled = 0;
        TInt count = 0;
        TBuf<256> appPath( _L(""));
        TBuf<64> fileName;

        // Find the path to the midlets app file, that gets created
        // when the midlet is installed
        while (result != RApaLsSession::ENoMoreAppsInList)
            {
            if (result == KErrNone)
                result = appSession.GetNextApp(appInfo);

            // GetNextApp ocasionally fails, hence the use of
            // handeled and count.
            if (result == KErrNone && count == handeled)
                {
                handeled++;
                count++;
                fileName.Copy(appInfo.iCaption);

                if (fileName.Compare(appName) == 0) //注:appName 是java程序的名称,即Application name
                    {
                    // Found the app we we're looking for.
                    appPath.Copy(appInfo.iFullName);
                    result = RApaLsSession::ENoMoreAppsInList;
                    }
                }
            else
                if (result == RApaLsSession::EAppListInvalid)
                    {
                    // Something failed, so the session is restarted.
                    count = 0;
                    appSession.Close();
                    if (appSession.Connect() == KErrNone
                            && appSession.GetAllApps() == KErrNone)
                        result = KErrNone;
                    }
            }
        RunAppL(appPath);
        }
    else
        {
        informationNote->ExecuteLD(_L("Failed to search for MIDLET"));;
        }
    appSession.Close();
    }

 

3)获得jar程序图标

根据MIDP 2.0特性,MIDIet图标必须包含在JAR中,如JAD文件中用到的MIDIet<n>属性。“JAR中的图标必须使用PNG图片,路径为大小写敏感的绝对路径”

因为JAR已经包含了图标,因此无法从文件中获取图标信息,但可以用MAknsSkinInstance从S60菜单获取MIDIet图标

RApaLsSession iApaSession;
TApaAppInfo appInfo;
iApaSession.GetAllApps();
MAknsSkinInstance* skin = AknsUtils::SkinInstance();
for(TInt i= 0; i < iAppCount; i++)
{
iApaSession.GetNextApp(appInfo);
//Filtering through the list to get Midlets from the list of applications
if(appInfo.iFullName.Right(8).Compare(_L(".fakeapp"))==0)
{
appInfo.iFullName; //Gives Name of the Midlet
appInfo.iUid; //Gives Uid of the Midlet
TRAPD(Err,
CFbsBitmap* midletIcon, midletIconMsk;
AknsUtils::CreateAppIconLC(skin,
appInfo.iUid,EAknsAppIconTypeList,
midletIcon,
midletIconMsk);
 
// midletIcon and midletIConMsk has the Icon and Mask respectively.
(Print them to see the icon)
);
}
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值