symbian 安裝啟動第三方程式

來源:互聯網
上載者:User

個人整理原創,如要轉載,請註明去處!以下無特殊說明,都是針對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)
);
}
}

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.