Symbian
Symbian OS Library

FAQ-0267 Can I make my Java app open a selected document like Word and Web do?

[Index][spacer] [Previous] [Next]



 

Classification: Java Category: Deployment
Created: 08/25/99 Modified: 09/01/2001
Number: FAQ-0267
Platform: ER5

Question:
When I tap twice on a Word document, it is opened up in the Word app. Likewise for HTML documents with Web. Can I do a similar thing with a Java app?

Answer:
The short answer is that this is possible in principle but not without C++ programming.
One should first distinguish two mechanisms that are in use here. The Word app recognizes its documents from the UID that is embedded within them, which associates them uniquely with the Word app. HTML documents by contrast are recognized by Web from their MIME type, which is determined in this case simply by their file extension. The first of these mechanisms, being o/s-dependent would clearly not be appropriate for a Java app.

MIME types are distinguished in the Symbian OS by .mdl recognizers (stored in the \System\Recogs folder) which make use of the file's extension and/or the format/layout of the contained data. Apps register their interest in a given mime type at a priority level specified by the their author in a datatype_list in their .aif file when they are installed (see "Aiftool resource file format" in C++ or OPL SDK documentation). The registered app expressing the highest priority is used by the system to try and open a document of any given mime type.

A discussion of the workings of recognizers and a sample recognizer providing an algorithm for identifyying text files is provided in the C++ Knowledge Base .

This mechanism works fine for Java apps, except that it does not provide a way for the document's name to be passed on to the Java app when the latter is started. Instead the Java app will be opened up with its default document. It should be possible to get around this limitation by writing an intermediate C++ app to parse the name of the selected file as a string and use that to construct a command line to launch the Java app with an argument string it can understand.

Methods are under consideration which might allow this to be accomplished more straightforwardly in a future Symbian OS Java release.