如何在Android应用中检索*的部分内容?

时间:2023-01-14 23:21:30

Basically, I want to retrieve content from wikipedia. But I want to display it inside my Android Apps directly. Not immidiately redirect to the internet browser, but to display it inside my apps first.

基本上,我想从*中检索内容。但我想在我的Android应用中直接显示它。不是直接重定向到internet浏览器,而是首先在我的应用程序中显示它。

Currently, I manage to request the Wikipedia API and get only the main content by using http://en.wikipedia.org/w/api.php?action=parse&prop=text&format=xml&page=Bla_Bla_Bla. and because I parse the data, I will use WebView to render in the Android. It successfully rendered. But only to those unprotected article...

目前,我通过使用http://en.wikipedia.org/w/api.php?由于我解析数据,我将使用WebView在Android中渲染。它成功地呈现。但只有那些没有保护的物品……

If it is protected such as Mona Lisa, the output was not rendered properly in the WebView Android.

如果它是受保护的,比如蒙娜丽莎,输出在WebView Android中没有被正确渲染。

I want to know has anybody try to retrieve a wikipedia content and display it in your android apps, easily and beautifully?

我想知道是否有人试图检索*的内容并将其显示在你的android应用程序中,既简单又美观?

Thank you :)

谢谢你:)

2 个解决方案

#1


3  

I have managed to find the answer. I think I over complicate this things. We can actually retrieve the content perfectly without calling the mediawiki API. Because They already provided the interface for mobile.

我设法找到了答案。我想我把这件事复杂化了。实际上,我们不需要调用mediawiki API就可以完美地检索内容。因为他们已经为移动设备提供了接口。

I just need to load http://en.m.wikipedia.org/wiki/ and add the topic at the back. Then View it using WebView. Displayed perfectly Nice. :)

我只需要加载http://en.m.wikipedia.org/wiki/并在后面添加主题。然后使用WebView查看它。显示非常好。:)

References: http://en.wikipedia.org/wiki/Help:Mobile_access#Official_online_version

引用:http://en.wikipedia.org/wiki/Help:Mobile_access # Official_online_version

#2


0  

I would probable retrieve the json version of the api call (with format=json in the request uri). You have managed to get the retrieval of the data (with an HttpPost or HttpGet, I guess) working, so now it's only a question of retrieving the correct data for use in your application.

我可能会检索api调用的json版本(请求uri中的format=json)。您已经成功地获取了数据的检索(使用HttpPost或HttpGet,我猜),所以现在只需要检索应用程序中使用的正确数据。

I'm currently writing an application that retrieves JSON from a server, and it's really easy to get the content. Just instantiate a JSONObject and feed it the json result from the server, then retrieve the data with the get methods in the object.

我目前正在编写一个从服务器检索JSON的应用程序,并且很容易获得内容。只需实例化一个JSONObject并将json结果从服务器提供给它,然后使用对象中的get方法检索数据。

Simple example:

简单的例子:

JSONObject jsonObject = new JSONObject(responseTextFromServer);
String query = jsonObject.getString("query");
// and so on...

#1


3  

I have managed to find the answer. I think I over complicate this things. We can actually retrieve the content perfectly without calling the mediawiki API. Because They already provided the interface for mobile.

我设法找到了答案。我想我把这件事复杂化了。实际上,我们不需要调用mediawiki API就可以完美地检索内容。因为他们已经为移动设备提供了接口。

I just need to load http://en.m.wikipedia.org/wiki/ and add the topic at the back. Then View it using WebView. Displayed perfectly Nice. :)

我只需要加载http://en.m.wikipedia.org/wiki/并在后面添加主题。然后使用WebView查看它。显示非常好。:)

References: http://en.wikipedia.org/wiki/Help:Mobile_access#Official_online_version

引用:http://en.wikipedia.org/wiki/Help:Mobile_access # Official_online_version

#2


0  

I would probable retrieve the json version of the api call (with format=json in the request uri). You have managed to get the retrieval of the data (with an HttpPost or HttpGet, I guess) working, so now it's only a question of retrieving the correct data for use in your application.

我可能会检索api调用的json版本(请求uri中的format=json)。您已经成功地获取了数据的检索(使用HttpPost或HttpGet,我猜),所以现在只需要检索应用程序中使用的正确数据。

I'm currently writing an application that retrieves JSON from a server, and it's really easy to get the content. Just instantiate a JSONObject and feed it the json result from the server, then retrieve the data with the get methods in the object.

我目前正在编写一个从服务器检索JSON的应用程序,并且很容易获得内容。只需实例化一个JSONObject并将json结果从服务器提供给它,然后使用对象中的get方法检索数据。

Simple example:

简单的例子:

JSONObject jsonObject = new JSONObject(responseTextFromServer);
String query = jsonObject.getString("query");
// and so on...