Question

En cliquant sur une URL affichée dans mon application en cours d'exécution sur un appareil Symbian S60 3ème édition devrait rendre le navigateur du téléphone (qui est déjà ouvert) ouvrir l'URL spécifiée.

Voici le code:

_LIT( KUrlPrefix,"4 " )

void CMunduIMAppUi::OpenInBrowser(const TDesC& aUrl)
    {
    HBufC *url = NULL;
    const TInt KWmlBrowserUid =0x10008D39; 
    TUid id( TUid::Uid( KWmlBrowserUid ) );
    TApaTaskList taskList( CEikonEnv::Static()->WsSession() );
    TApaTask task = taskList.FindApp( id );

    // Checks if the browser is already open
    if ( task.Exists() )
        {
        HBufC8* parameter = HBufC8::NewL( aUrl.Length()+ KUrlPrefix().Length());
        parameter->Des().Copy(KUrlPrefix);
        parameter->Des().Append(aUrl);

        task.BringToForeground();
        task.SendMessage(TUid::Uid(0), *parameter); // UID not used

        delete parameter;
        parameter = NULL;
        }
    }

Quand j'utilise ce code pour ouvrir une URL du navigateur vient au premier plan, mais ne soit pas dirigé vers l'URL.

Je soupçonne que quelque chose ne va pas dans l'appel SendMessage qui est appelé après le navigateur est portée à l'avant-plan:

task.SendMessage(TUid::Uid(0), *parameter); // UID not used
Était-ce utile?

La solution

Peut-être qu'il serait plus frais pour ouvrir le lien dans votre application à la place:

    _LIT( KTestUrlPrefix,"4 " );
iOverriddenSettings = new (ELeave) TBrowserOverriddenSettings;
iOverriddenSettings->SetBrowserSetting( EBrowserOverSettingsSmallScreen, EBrowserOverFullScreenValueSoftKeysOnly);//(TUint) 1 );
iOverriddenSettings->SetBrowserSetting( EBrowserOverSettingsAutoLoadImages, (TUint) 1 );
iOverriddenSettings->SetBrowserSetting( EBrowserOverSettingsFontSize, (TUint) 0 );
iOverriddenSettings->SetBrowserSetting( EBrowserOverSettingsFullScreen, EBrowserOverFullScreenValueNormal);//(TUint) 0 );
iOverriddenSettings->SetBrowserSetting( EBrowserOverSettingsCustomAp, (TUint) iIAP ); //access point ID 


HBufC* parameter = HBufC::NewLC( KTestUrlPrefix().Length() + aLink.Length() );
parameter->Des().Copy( KTestUrlPrefix );
parameter->Des().Append( aLink );
if(iLauncher)
{
    delete iLauncher;
    iLauncher = NULL;
}
iLauncher = CBrowserLauncher::NewL();
iLauncher->LaunchBrowserEmbeddedL( *parameter, NULL, NULL, iOverriddenSettings );
CleanupStack::PopAndDestroy();

Autres conseils

Je l'ai utilisé avec succès ce code, que je crois que je suis arrivé du Forum Nokia:


    RApaLsSession apaLsSession;
    //Note that the UID of the OSS browser in S60 3rd Edition is 0x1020724D
    //and from S60 3rd Edition, FP1 onwards 0x10008D39.
    const TUid KOSSBrowserUidValue = {0x10008D39};
    //Parameter type 4: Start/Continue the browser specifying a URL =>
    //Parameter = "4"+" "+""
    _LIT(KParam4, "4 ");


    HBufC* param = HBufC::NewLC(KParam4().Length()+aUrl.Length());
    param->Des().Copy(KParam4);
    param->Des().Append(aUrl);

    //Find the browser application
    TUid id(KOSSBrowserUidValue);
    TApaTaskList taskList(iEikonEnv->WsSession());
    TApaTask task = taskList.FindApp(id);
    if(task.Exists())
        {
        //Continue the application
        task.BringToForeground();
        HBufC8* param8 = HBufC8::NewLC(param->Length());
        param8->Des().Append(*param);
        task.SendMessage(TUid::Uid(0), *param8); // UID not used
        CleanupStack::PopAndDestroy(param8);
        }
    else
        {
        if(!apaLsSession.Handle())
            {
            User::LeaveIfError(apaLsSession.Connect());
            CleanupClosePushL(apaLsSession);
            }
        //Start the application
        TThreadId thread;
        User::LeaveIfError(apaLsSession.StartDocument(*param, KOSSBrowserUidValue, thread));
        CleanupStack::PopAndDestroy(&apaLsSession);//   .Close();
        }
    CleanupStack::PopAndDestroy(param);

Vous pouvez facilement le faire avec Qt, si vous ne me dérange pas une dépendance sur Qt.

QDesktopServices::openUrl(QUrl("http://yoursite.com/"));

Hope this helps.

Avez-vous essayé l'API de lancement du navigateur qui est documenté et peut être téléchargé ici ?

Vous avez besoin de la capacité SwEvent pour TApaTask :: SendMessage (mais ce n'est pas mentionné dans la documentation).

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top