Join Now
Quality Rating:
  • Currently 0.0 / 5
(0.0 / 5 - 0 votes cast)
Expertise Level:
  • Currently 0.0 / 5
(0.0 / 5 - 0 votes cast)

This page was last modified 12:30, 17 July 2008.

Launching default application based on MIME type

From Forum Nokia Wiki

This article explains how to launch default application to open a file based on its MIME type. For example, you can launch the default video player to open .3gp or .mp4 files or launch the default browser to open HTML files. In Windows programming, it is basically the equivalent of ShellExecuteEx function.

The class that you need to launch default application is RApaLsSession. There are basically two steps you need to do. The first step, you need to get the MIME type of your file by calling RApaLsSession::AppForDocument(). You will get the MIME type and also the UID of the application that is associated with the MIME type.

The second step, start the application using the MIME type or UID of the application. This can be done by calling RApaLsSession::StartDocument().

The code below shows how you can launch default application to view a file based on its MIME type.

#include <APGCLI.H>
 
RApaLsSession session;
User::LeaveIfError(session.Connect());
CleanupClosePushL(session);
 
// Gets the UID and MIME type for the given file name.
TUid uid;
TDataType dataType;
User::LeaveIfError(session.AppForDocument(aFileName, uid, dataType));
 
// Runs the default application using the MIME type, dataType.
// You can also use the UID to run the application. 
TThreadId threadId;
User::LeaveIfError(session.StartDocument(aFileName, dataType, threadId));
 
CleanupStack::PopAndDestroy(); // session

To compile the code above you need to #include a header file apgcli.h and link against two libraries, apgrfx.lib and apmime.lib.


Related:

Related Discussions
Thread Thread Starter Forum Replies Last Post
File asscociativity for 60 S 3rd Edition ibraheemJazba Mobile Java General 5 2006-09-25 19:27
Problem download via OTA mcmcdonald Mobile Java General 2 2004-01-03 20:26
OTA downloading lakechat Mobile Java Networking & Messaging & Security 9 2006-12-26 17:12
XHTML Mime Types and User Agents Nokia_Archive Browsing and Mark-ups 1 1970-01-01 02:00
XHTML Mime Types and User Agents Nokia_Archive Browsing and Mark-ups 1 2002-05-22 10:40
 
Powered by MediaWiki
     
     RDF Facets:
     
     
     qfnZtypeQUqfnTypeZCommunityContentQ
     qfnZtypeQUqfnTypeZWebpageQ
     qfnZtypeQUqfnTypeZWikiContentQ
     qmarsZlanguageQUxhttpE3aE2fE2fswE2enokiaE2ecomE2flanguageE2d1E2fenX