之前的android项目中没有接触过https的请求,在目前实习公司接手的项目中,用到了https的请求,为了私密起见,需要在发起请求之前进行授权认证,客户端可以通过这种写法进行认证
Authenticator.setDefault(new Authenticator() {
int retryCount = 0;//目前重试次数
int maxRetryCount = 1;//最大重试次数
protected PasswordAuthentication getPasswordAuthentication() {
// this condition is set to prevent Authenticator from sending
// multiple authentication requests on a bad login
if<