Namespaces

Variants
Actions

Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries over the next few weeks. Thanks for all your past and future contributions.

Launch default web browser using Symbian C++

From Wiki
Jump to: navigation, search
Article Metadata
Tested with
Devices(s): Symbian^1, Symbian^3
Compatibility
Platform(s): Symbian C++ / Qt
Article
Keywords: Browser, RApaLsSession, MIME
Created: User:Kbwiki (20 Apr 2011)
Last edited: hamishwillee (02 Jul 2012)

Contents

Overview

Starting with Symbian^1, a plug-in in the global settings allows the user to select the default handler application for certain MIME types and for certain use case categories. This setting can be found on a device in Settings > Application Settings > Default applications. Unfortunately some applications (including 3rd Party Apps) do not obey this setting (for example they will open the standard Nokia browser even if Opera is set as the default).

This technical solution demonstrates how a third party application can start the mobile device user's preferred/default browser rather than the default supplied with the device. On earlier versions of the platform, this solution could still work, but 3rd party applications would have to be used for setting the MIME type handler.

Description

On Symbian^3 devices, there are 2 different settings views for Default Applications. One is the Simplified View (the default view). The other is the Advanced View, which can be opened using Options > Advanced options in the Simplified View.

When the setting for Browsing Internet is changed in the Simplified View, the setting in Advanced View for Text/HTML changes automatically. However, this does not happen the other way around, so a situation is possible where Simplified View shows Opera as Default for Browsing Internet, and Advanced View shows Open Text/HTML as Web.

When an application is launched using the document handler, it takes the setting from Advanced Settings. So, even though Browsing Internet shows Opera, Browser NG is launched using the document handler.

Solution

Header Files: apgcli.h
Libraries: apgrfx.lib

RApaLsSession lsSession;
// create a session with apparc server.
User::LeaveIfError(lsSession.Connect());
CleanupClosePushL(lsSession);
TDataType mimeDatatype(_L8("application/x-web-browse"));
TUid handlerUID;
// get the default application uid for application/x-web-browse
lsSession.AppForDataType(mimeDatatype,handlerUID);
// there may not be a mime-type handler defined, especially on S60 3.x
// in such case we default to the built-in browser
if (handlerUID.iUid == 0)
handlerUID = KWmlBrowserUid;
// Finally launch default browser
_LIT(KBrowserUrl,"http://www.google.com");
LaunchBrowserL(KBrowserUrl, handlerUID);
// Cleanup
CleanupStack::PopAndDestroy(&lsSession);

Notes

The LaunchBrowserL() method and KWmlBrowserUid are defined in How to Launch Browser in 3rd edition but the signature of the method needs to be modified to pass the UID of the Handler Application as follows:

 void LaunchBrowserL(const TDesC& aUrl, TUid& aUid);

See also Creating a handler application for a MIME type using Symbian C++ for information on how to declare your application as capable to handle specific MIME types.

This page was last modified on 2 July 2012, at 11:03.
50 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.

 

Thank you!

We appreciate your feedback.

×