在BlackBerry上打开pdf,doc,ppt或xls

时间:2010-12-02 13:36:53

标签: blackberry

如何在BlackBerry上以编程方式打开pdf,doc,ppt或xls?

1 个答案:

答案 0 :(得分:4)

最好的方法是购买第三方查看器并启动它以查看文档:

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");
}