如何在android中进行http认证
我正在使用以下代码
public void executeHttpGet() throws Exception {
dialog = new ProgressDialog(this);
dialog.setCancelable(true);
// set a message text
dialog.setMessage("Loading...");
// show it
dialog.show();
BufferedReader in = null;
HttpClient client = new DefaultHttpClient();
HttpGet request = new HttpGet();
String url= "http://newdev.objectified.com/morris/interface/mobile.php?method=dealerLogin&username=alixxxxxxxx&password=jamali";
request.setURI(new URI(url));
HttpResponse response = client.execute(request);
in = new BufferedReader
(new InputStreamReader(response.getEntity().getContent()));
StringBuffer sb = new StringBuffer("");
String line = "";
String NL = System.getProperty("line.separator");
while ((line = in.readLine()) != null) {
sb.append(line + NL);
}
in.close();
String page = sb.toString();
Toast.makeText(this, page, Toast.LENGTH_LONG).show();
// dialog.dismiss();
}
现在我想对此进行http身份验证,请帮忙吗?
I am using following code
public void executeHttpGet() throws Exception {
dialog = new ProgressDialog(this);
dialog.setCancelable(true);
// set a message text
dialog.setMessage("Loading...");
// show it
dialog.show();
BufferedReader in = null;
HttpClient client = new DefaultHttpClient();
HttpGet request = new HttpGet();
String url= "http://newdev.objectified.com/morris/interface/mobile.php?method=dealerLogin&username=alixxxxxxxx&password=jamali";
request.setURI(new URI(url));
HttpResponse response = client.execute(request);
in = new BufferedReader
(new InputStreamReader(response.getEntity().getContent()));
StringBuffer sb = new StringBuffer("");
String line = "";
String NL = System.getProperty("line.separator");
while ((line = in.readLine()) != null) {
sb.append(line + NL);
}
in.close();
String page = sb.toString();
Toast.makeText(this, page, Toast.LENGTH_LONG).show();
// dialog.dismiss();
}
Now I want to do http authentication on this ,please help?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
它应该看起来像这样:
It should look like this:
对于 http 身份验证,
Authenticator
类是您的朋友。For http authentication the
Authenticator
class is your friend.