如何访问一个网页内容(POST / GET)的Andr​​oid应用程序?应用程序、网页、内容、GET

由网友(软肋)分享简介:我的要求是非常相似这个问题。基本上,我将有我的Andr​​oid应用程序登录的活动,当用户输入数据并点击登录,我打我的网站,认证用户,得到的结果回来,引导用户进一步基于登录成功或不是。下面是我的问题。 什么是执行上面的android的选择我吗?我怎样才能POST数据并取回我的活动结果?如果WebViews时,可以这样...

我的要求是非常相似这个问题。

基本上,我将有我的Andr​​oid应用程序登录的活动,当用户输入数据并点击登录,我打我的网站,认证用户,得到的结果回来,引导用户进一步基于登录成功或不是。

下面是我的问题。

什么是执行上面的android的选择我吗?我怎样才能POST数据并取回我的活动结果? 如果WebViews时,可以这样简单? 解决方案

您可以张贴到URI与的HttpClient

  URI URI = URI.create(http://whatever.com/thingie);
HttpPost后=新HttpPost(URI);
StringEntity ENT =新StringEntity(这是我的数据!);
post.setEntity(ENT);
HttpClient的HttpClient的=新DefaultHttpClient();
HTT presponse响应= httpClient.execute(要求);
 

所有你需要看的东西在包 org.apache.http.client 。有一个良好的数额进一步的例子在那里在互联网上帮助你。

My requirement is very much similar to this question.

Basically, I will be having a login Activity in my android app and when the user enters data and clicks login, I have to hit my website, authenticates users, get the result back and guide the user further based on login success or not.

Here are my questions.

what are the options for me to implement the above in android? How can I POST data and get results back in my Activity? If WebViews are used, can this be simplified?

解决方案

You can POST to a URI with HttpClient:

URI uri = URI.create("http://whatever.com/thingie");
HttpPost post = new HttpPost(uri);
StringEntity ent = new StringEntity("Here is my data!");
post.setEntity(ent);
HttpClient httpClient = new DefaultHttpClient();
HttpResponse response = httpClient.execute(request);

All the stuff you need to look at is in the package org.apache.http.client. There is a good amount of further examples out there on the internet to help you.

阅读全文

相关推荐

最新文章