请注意,这是一个关于 MIDlet 的问题,即 Java ME(不是“普通”Java SE)。
我正在寻找使用 JSR 211 在手机上调用内容的正确方法,即 CHAPI - Content Handler API。我总是在下面的代码中找到 IOException。我正在运行的手机支持 JSR 211(它是索尼爱立信 C902)。
doInvoke("file:///e:/jpgimage.jpg"); //earlier in the code
void doInvoke(final String url) {
(new Thread() {
public void run() {
try {
Registry registry = Registry.getRegistry(this.getClass().getName());
Invocation invoc = new Invocation(url);
invoc.setAction(ContentHandler.ACTION_OPEN);
boolean mustExit = registry.invoke(invoc);
if (mustExit) {
notifyDestroyed();
} else {
// stay put
}
} catch (IOException ex) {
ex.printStackTrace();
}
}
}).start();
}