你好,我是 Yassine,我是 android 开发的新手。我想创建一个从 WolframAlpha 网站检索答案的简单应用程序。而且我遇到了很多错误。这是我的代码的一部分:
`//Get The Search Input From The Main Activity
String sciSearch = myIntent.getStringExtra(HomeActivity.EXTRA_MESSAGE);
//Call WAengine
WAEngine engine = new WAEngine();
Log.d("Engine","Engine Was Created");
//Check The App Id
engine.setAppID(appid);
Log.d("AppId","App Selected");
engine.addFormat("plaintext");
//Create A Query
WAQuery query = engine.createQuery();
//Submit The Query
query.setInput(sciSearch);
//Get Results
//Print The Url
result = (TextView) findViewById(R.id.title);
content = (TextView) findViewById(R.id.content);
//String url = engine.toURL(query);
//result.setText(url);
//Here is The Problem
try{
Log.d("Query Performed","The Query was not performed");
WAQueryResult queryResult = engine.performQuery(query);
Log.d("Query Performed","The Query was performed");
for(WAPod pod : queryResult.getPods()){
if(!pod.isError()){
Log.d("Pod",pod.getTitle());
//result.setText(pod.getTitle());
for (WASubpod subpod : pod.getSubpods()) {
for (Object element : subpod.getContents()) {
if (element instanceof WAPlainText) {
//content.setText(((WAPlainText) element).getText());
Log.d("Content",((WAPlainText) element).getText());
}
}
}
}
}
}catch (WAException e) {
e.printStackTrace();
}`
当我检查 Logcat 时,它会记录第一个错误的查询未执行。然后我收到另一个错误的“URLFetcher”作为标签,它说异常下载 URL http://api.wolframalpha.com/v2/query?appid=XXX&input=pi&format=PLAINTEXT&async=false&reinterpret=true 然后是另一个也是最后一个错误标签: EGL_genymotion 说 eglSurfaceAttrib 没有实现。我希望我很清楚,我已经检查了请求的 url,它返回一个 xml 文件,所以我应该只使用 XmlPullParser 来解析它,而不是使用 Wolframe 库中的默认文件。抱歉,如果我的代码不专业,我仍在为自己工作(将做一些重构):)。谢谢。