Reputation: 8741
How do I open pdf, doc, ppt or xls programmatically on a BlackBerry?
Upvotes: 1
Views: 1395
Reputation: 146
The best approach is to purchase a 3rd-party viewer and launch that to view the document:
String path = "file://SDCard/info.doc";
String contentType = MIMETypeAssociations.getMIMEType(path);
Invocation invocation = new Invocation(path, contentType, null, false, ContentHandler.ACTION_OPEN);
Registry registry = Registry.getRegistry(MyApp.class.getName());
try {
ContentHandler[] handlers = registry.findHandler(invocation);
if (handlers != null && handlers.length > 0) {
invocation.setID(handlers[0].getID());
registry.invoke(invocation);
} else {
Dialog.alert("Error");
}
} catch (Exception e) {
Dialog.alert("Error");
}
Upvotes: 4