views:

135

answers:

2

I was wondering if it's possible to open doc, xls, pdf, etc files using the "Documents To Go" app from a third party blackberry app.

+1  A: 

You can use the ApplicationManager class to launch other applications, for example by looking up its descriptor and using runApplication(). You can also pass arguments in the descriptor and if the application looks at arguments passed into it, it may actually open the specified file.

Marc Novakowski
+2  A: 

If you want to open a specific document, since Docs ToGo registers to handle these extensions, you can use the Registry invocation and it will be handled for you. Take a look at the Registry and Invocation classes, the following code will open the document in the given path, Docs ToGo will take over through the Registry:

Invocation invocation = new Invocation(path);
Ragistry reg =  = Registry.getRegistry("<your app namespace.class>");
reg.invoke(invocation);

If there is no registered handler for the file content type a ContentHandlerException will be thrown with error code ContentHandlerException.NO_REGISTERED_HANDLER.

Note: there's a small bug in Docs ToGo - closing the document or clicking the back button might not lead the user back to your application.

EDIT: The getRegistry function takes a class fully qualified name e.g. com.softartisans.SilverDust, where SilverDust is the class mane. You can find more info about the use of the Registry in this online book starting page 291 - Client use of Registry. I originally linked to the javax Registry, but it is more useful to look at the BlackBerry Registry docs.

Tamar
what do you mean by "<your app namespace>"?
hishboy
I've added info about the registry. Also I originally gave the link to the Registry at the javax docs, but it is probably more useful to look at it in the BB docs.
Tamar