gpt4 book ai didi

java - 使用内容处理程序 API (JSR 211) 打开应用程序

转载 作者:太空宇宙 更新时间:2023-11-04 08:48:07 26 4
gpt4 key购买 nike

我希望能够使用诺基亚 6212 上的内容处理程序 API (JSR 211) 通过我的应用程序启动 native 应用程序和 J2ME 应用程序。

目前,我无法这样做,因为它总是声明“未找到内容处理程序”并抛出 javax.microedition.content.ContentHandlerException

目前,我正在尝试让手机启动浏览器并访问某个网站,只是为了测试我是否可以使用该框架。我尝试了许多不同的 Inspiration 对象:

//throw exceptions
new Invocation("http://www.somesite.com/index.html",
"application/internet-shortcut");
new Invocation("http://www.google.co.uk","text/html");
// a long shot, I know
new Invocation("http://www.somesite.com/text.txt","text/plain");
// massive long shot
new Invocation("http://www.google.co.uk","application/browser");

//appears to download the link and content (and definitely does in the Nokia
// emulator) and then throws an exception
new Invocation("http://www.google.co.uk");
new Invocation("http://www.somesite.com/index.html");

下面是我一直在使用的代码,请记住经常更改的参数以生成不同的 Inspiration 对象。

/*
* Invokes an application using the Content Handler API
*/
public void doInvoke(String url, String mime, String payload){
Registry register = Registry.getRegistry(this.getClass().getName());
Invocation invoke = new Invocation(url, mime, null, false,
ContentHandler.ACTION_OPEN);

boolean mustQuit = false;

try {
mustQuit = register.invoke(invoke);
} catch (IllegalArgumentException e) {
e.printStackTrace();
} catch (ContentHandlerException e) {
e.printStackTrace();
} catch (SecurityException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}

if(mustQuit){
this.quit();
}
}

最佳答案

试试这个:

Registry register = Registry.getRegistry(this.getClass().getName());

您必须为 MIDlet 继承者调用 Registry.getRegistry。只需使用您的 MIDlet 来获取类名即可。

关于java - 使用内容处理程序 API (JSR 211) 打开应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3925945/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com