import java.io.IOException;
import java.util.ArrayList;
Import the Java. Util. HashMap;
Import the Java. Util. List;
import java.util.regex.Matcher;
Import the Java. Util. Regex. The Pattern;
The import okhttp3. Call;
The import okhttp3. Callback;
The import okhttp3. Cookies;
The import okhttp3. CookieJar;
The import okhttp3. FormBody;
The import okhttp3. HttpUrl;
The import okhttp3. OkHttpClient;
The import okhttp3. Request;
The import okhttp3. The Response;
The import android. App. The Activity;
The import android. Content. Intent;
The import android. Graphics. Bitmap;
The import android. Graphics. BitmapFactory;
The import android. OS. Bundle;
The import android. OS. Handler;
The import android. OS. The Message;
The import android. The provider. Settings. The System;
The import android. Util. Base64;
The import android. Util. Log;
The import android. View. The view;
The import android. View. The view. An OnClickListener;
The import android. Widget. The Button;
The import android. Widget. The EditText;
The import android. Widget. ImageView;
The import android. Widget. ListView.
The import android. Widget. TextView;
Public class Jwccx extends the Activity {
ArrayList
ArrayList
The EditText edusrname;
The EditText edpassword;
The EditText edcode;
ModelApplication lModel;
ImageView imvcode;
The Button btnlog;
Handler Handler.
OkHttpClient httpClient.
ListView mylist.
String mainurl="http://42.247.3.125/jsxsd";
String codeurl="http://42.247.3.125/jsxsd/verifycode.servlet";
String postlogourl="http://42.247.3.125/jsxsd/xk/LoginToXk";
String cjcxstrString="http://42.247.3.125/jsxsd/kscj/cjcx_query?" ;
String cjliststr="http://42.247.3.125/jsxsd/kscj/cjcx_list";
Private HashMap
Public void geturlandCode ()
{
//1 url 2. Code cookies
Request the Request=new Request. The Builder (). The url (mainurl). The build ();
HttpClient. NewCall (request). The enqueue (new Callback () {
@ Override
Public void onResponse (Call arg0, Response arg1) throws IOException {
//TODO Auto - generated method stub
HttpClient=new OkHttpClient. Builder (). CookieJar (new cookieJar () {
@ Override
Public void saveFromResponse (HttpUrl HttpUrl List
//TODO Auto - generated method stub
CookieStore. Put (httpUrl. Host (), a list).
}
@ Override
Public List
//TODO Auto - generated method stub
List
//for (int I=0; i
//}
Return the cookies!=null ? Cookies: new ArrayList
}
}). The build ();
Request request2=new Request. The Builder (). The url (codeurl). The build ();
The Response response2=httpClient. NewCall (request2). The execute ();
Byte [] picbytes=response2. Body () bytes ();
The Message MSG=handler. ObtainMessage ();
MSG. What=1;
MSG. Obj=picbytes;
Handler. SendMessage (MSG);
}
@ Override
Public void onFailure (Call arg0, IOException arg1) {
//TODO Auto - generated method stub
}
});
}
Public void chaxuncj ()
{
Request the Request=new Request. The Builder (). The url (cjcxstrString). The build ();
HttpClient=new OkHttpClient. Builder (). CookieJar (new cookieJar () {
@ Override
Public void saveFromResponse (HttpUrl HttpUrl List
//TODO Auto - generated method stub
CookieStore. Put (httpUrl. Host (), a list).
}
@ Override
Public List
//TODO Auto - generated method stub
List
//
Return the cookies!=null ? Cookies: new ArrayList
}
}). The build ();
HttpClient. NewCall (request). The enqueue (new Callback () {
@ Override
Public void onResponse (Call arg0, Response arg1) throws IOException {
//TODO Auto - generated method stub
Request request2=new Request. The Builder (). The url (cjliststr). The build ();
HttpClient=new OkHttpClient. Builder (). CookieJar (new cookieJar () {
@ Override
Public void saveFromResponse (HttpUrl HttpUrl List
//TODO Auto - generated method stub
CookieStore. Put (httpUrl. Host (), a list).
}
@ Override
Public List
//TODO Auto - generated method stub
List
//
Return the cookies!=null ? nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull