Log如下
10-01 09:57:38.358 23871-23871/com.pyh.pc.ticket_2 E/Trace﹕ error opening trace file: No such file or directory (2)
10-01 09:57:38.398 23871-23871/com.pyh.pc.ticket_2 W/dalvikvm﹕ Refusing to reopen boot DEX '/system/framework/hwframework.jar'
10-01 09:57:39.109 23871-23871/com.pyh.pc.ticket_2 I/Adreno200-EGL﹕ : EGL 1.4 QUALCOMM build: (CL2924417)
Build Date: 08/22/13 Thu
Local Branch: Huawei_01270965
Remote Branch:
Local Patches:
Reconstruct Branch:
10-01 09:57:39.450 23871-23871/com.pyh.pc.ticket_2 I/Choreographer﹕ Skipped 34 frames! The application may be doing too much work on its main thread.
10-01 09:58:14.227 23871-23871/com.pyh.pc.ticket_2 W/System.err﹕ Invalid int: ""
10-01 09:58:16.139 23871-23871/com.pyh.pc.ticket_2 I/info﹕ 不会挂在了这把
10-01 09:58:16.139 23871-23871/com.pyh.pc.ticket_2 I/info﹕ 不会挂在了这把22
10-01 09:58:16.369 23871-23871/com.pyh.pc.ticket_2 I/tag﹕ 2016-10-01
10-01 09:58:16.369 23871-23871/com.pyh.pc.ticket_2 I/tag﹕ 广州
10-01 09:58:16.369 23871-23871/com.pyh.pc.ticket_2 I/tag﹕ 深圳
10-01 09:58:16.499 23871-23871/com.pyh.pc.ticket_2 I/info﹕ 挂在哪里卧槽
10-01 09:58:16.499 23871-23871/com.pyh.pc.ticket_2 I/info﹕ 挂在哪里卧槽222
10-01 09:58:16.509 23871-23871/com.pyh.pc.ticket_2 I/info﹕ 挂在这了卧槽
10-01 09:58:16.569 23871-23871/com.pyh.pc.ticket_2 I/info﹕ 挂在这了卧槽
10-01 09:58:16.579 23871-23871/com.pyh.pc.ticket_2 I/tag﹕ 2016-10-01
10-01 09:58:16.579 23871-23871/com.pyh.pc.ticket_2 I/tag﹕ 广州
10-01 09:58:16.579 23871-23871/com.pyh.pc.ticket_2 I/tag﹕ 深圳
10-01 09:58:16.940 23871-23875/com.pyh.pc.ticket_2 E/dalvikvm﹕ GC_CONCURRENT freed 2610K, 21% free 13449K/16899K, paused 19ms+5ms, total 70ms
10-01 09:58:16.940 23871-25428/com.pyh.pc.ticket_2 I/info﹕ 挂在这了卧槽22
10-01 09:58:17.160 23871-25428/com.pyh.pc.ticket_2 I/info﹕ 挂在这了卧槽333
10-01 09:58:17.160 23871-25428/com.pyh.pc.ticket_2 I/info﹕ 挂在这了卧槽444
10-01 09:58:17.270 23871-25428/com.pyh.pc.ticket_2 I/tag﹕ 搞定了
10-01 09:58:17.280 23871-23871/com.pyh.pc.ticket_2 I/info﹕ 已执行完
10-01 09:58:17.310 23871-23871/com.pyh.pc.ticket_2 W/ResourceType﹕ Failure getting entry for 0x7f07001b (t=6 e=27) in package 0 (error -75)
10-01 09:58:17.310 23871-23871/com.pyh.pc.ticket_2 W/dalvikvm﹕ threadid=1: thread exiting with uncaught exception (group=0x42651438)
Intent intent = getIntent();
String date3 = intent.getStringExtra("date1");
String startStation = intent.getStringExtra("from");
String arriveStation = intent.getStringExtra("to");
Log.i("tag", date3);
Log.i("tag", startStation);
Log.i("tag", arriveStation);
String[] city = getCityCode(startStation, arriveStation);
findTiket(date3, city[0], city[1]);
}
public void findTiket(final String date, final String start, final String end) {
new Thread(new Runnable() {
@Override
public void run() {
try {
String str = "https://kyfw.12306.cn/otn/lcxxcx/query?purpose_codes=ADULT&queryDate="+date+"&from_station="+start+"&to_station="+end+"";
URL url = new URL(str);
SSLContext sslctxt = SSLContext.getInstance("TLS");
sslctxt.init(null, new TrustManager[]{new MyX509TrustManager()}, new java.security.SecureRandom());
HttpsURLConnection conn = (HttpsURLConnection) url.openConnection();
conn.setSSLSocketFactory(sslctxt.getSocketFactory());
conn.setHostnameVerifier(new MyHostnameVerifier());
conn.connect();
int code = conn.getResponseCode();
if (code == 200) {
InputStream input = conn.getInputStream();
String result = toString(input);
if (result != null) {
list = TableName.parseJsonTiket(result);
if (list != null && list.size() > 0) {
handler.sendEmptyMessage(1);
} else {
handler.sendEmptyMessage(0);
}
} else {
handler.sendEmptyMessage(2);
}
input.close();
}
conn.disconnect();
} catch (Exception e) {
e.printStackTrace();
}
}
private String toString(InputStream input) {
String content = null;
try {
InputStreamReader ir = new InputStreamReader(input);
BufferedReader br = new BufferedReader(ir);
StringBuilder sbuff = new StringBuilder();
while (null != br) {
String temp = br.readLine();
if (null == temp) break;
sbuff.append(temp).append(System.getProperty("line.separator"));
}
content = sbuff.toString();
} catch (Exception e) {
e.printStackTrace();
}
return content;
}
}).start();
;
}
static class MyX509TrustManager implements X509TrustManager {
@Override
public void checkClientTrusted(X509Certificate[] chain, String authType)
throws CertificateException {
}
@Override
public void checkServerTrusted(X509Certificate[] chain, String authType)
throws CertificateException {
}
@Override
public X509Certificate[] getAcceptedIssuers() {
return null;
}
}
static class MyHostnameVerifier implements HostnameVerifier {
@Override
public boolean verify(String hostname, SSLSession session) {
return true;
}
}
Handler handler = new Handler() {
@Override
public void handleMessage(Message msg) {
if (msg.what == 0) {
if (dialog != null && dialog.isShowing()) {
dialog.dismiss();
}
Toast.makeText(QueryResultActivity2.this, "没有符合条件的数据,请更换日期!", Toast.LENGTH_SHORT).show();
} else if (msg.what == 2) {
if (dialog != null && dialog.isShowing()) {
dialog.dismiss();
}
Toast.makeText(QueryResultActivity2.this, "服务器没响应!", Toast.LENGTH_SHORT).show();
} else if (msg.what == 1) {
tiketView(list);
}
}
};
public void insert() {
for (int i = 0; i < TranDate.city.length && i < TranDate.cityCode.length; i++) {
map.put(TranDate.city[i], TranDate.cityCode[i]);
}
}
public String[] getCityCode(String start, String end) {
String[] code = new String[2];
code[0] = map.get(start);
code[1] = map.get(end);
return code;
}
public void tiketView(List<Map<String, String>> list) {
simpleAdapter = new SimpleAdapter(QueryResultActivity2.this, list, R.layout.tiket_listview, new String[]{"车次", "起始站", "终点站", "出发时间", "到达时间", "历时", "商务座", "特等座", "一等座", "二等座", "高级软卧", "无座", "软卧", "硬卧", "硬座", "软座", "日期", "备注", "info"},
new int[]{R.id.tiket_listview_trannumber, R.id.tiket_listview_start, R.id.tiket_listview_end,
R.id.tiket_listview_starttime, R.id.tiket_listview_endtime, R.id.tiket_listview_lishi,
R.id.tiket_listview_swz, R.id.tiket_listview_tdz, R.id.tiket_listview_ydz,
R.id.tiket_listview_edz, R.id.tiket_listview_gjrw, R.id.tiket_listview_wz,
R.id.tiket_listview_rw, R.id.tiket_listview_yw, R.id.tiket_listview_yz,
R.id.tiket_listview_rz, R.id.tiket_listview_date, R.id.tiket_listview_remark, R.id.tiket_listview_info
});
tiketList.setAdapter(simpleAdapter);
Log.i("info", "已执行完");
}
}
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:orientation="vertical" >
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:id="@+id/tiket_listview_trannumber"
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="match_parent"
android:singleLine="true"
android:text="车次:" />
<TextView
android:id="@+id/tiket_listview_start"
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="match_parent"
android:singleLine="true"
android:text="起始站:" />
<TextView
android:id="@+id/tiket_listview_end"
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="match_parent"
android:singleLine="true"
android:text="终点站:" />
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:layout_weight="1"
android:id="@+id/tiket_listview_starttime"
android:layout_width="0dp"
android:layout_height="match_parent"
android:singleLine="true"
android:text="出发时间:" />
<TextView
android:layout_weight="1"
android:id="@+id/tiket_listview_endtime"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginLeft="5dp"
android:singleLine="true"
android:text="到达时间:" />
<TextView
android:id="@+id/tiket_listview_lishi"
android:layout_weight="1"
android:layout_width="0dp"
android:singleLine="true"
android:layout_height="match_parent"
android:layout_marginLeft="5dp"
android:text="历时:" />
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:id="@+id/tiket_listview_swz"
android:layout_weight="1"
android:layout_width="0dp"
android:singleLine="true"
android:textColor="@color/red"
android:layout_height="match_parent"
android:text="商务座:" />
<TextView
android:id="@+id/tiket_listview_tdz"
android:layout_weight="1"
android:layout_width="0dp"
android:singleLine="true"
android:textColor="@color/red"
android:layout_height="match_parent"
android:text="特等座:" />
<TextView
android:id="@+id/tiket_listview_ydz"
android:layout_weight="1"
android:layout_width="0dp"
android:singleLine="true"
android:textColor="@color/red"
android:layout_height="match_parent"
android:text="一等座:" />
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:id="@+id/tiket_listview_edz"
android:layout_weight="1"
android:layout_width="0dp"
android:singleLine="true"
android:textColor="@color/red"
android:layout_height="match_parent"
android:text="二等座:" />
<TextView
android:id="@+id/tiket_listview_gjrw"
android:layout_weight="1"
android:layout_width="0dp"
android:singleLine="true"
android:textColor="@color/red"
android:layout_height="match_parent"
android:text="高级软卧:" />
<TextView
android:id="@+id/tiket_listview_wz"
android:layout_weight="1"
android:layout_width="0dp"
android:singleLine="true"
android:textColor="@color/red"
android:layout_height="match_parent"
android:text="无座:" />
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:id="@+id/tiket_listview_rw"
android:layout_weight="1"
android:layout_width="0dp"
android:singleLine="true"
android:textColor="@color/red"
android:layout_height="match_parent"
android:text="软卧" />
<TextView
android:id="@+id/tiket_listview_yw"
android:layout_weight="1"
android:layout_width="0dp"
android:singleLine="true"
android:textColor="@color/red"
android:layout_height="match_parent"
android:text="硬卧" />
<TextView
android:id="@+id/tiket_listview_yz"
android:layout_weight="1"
android:layout_width="0dp"
android:singleLine="true"
android:textColor="@color/red"
android:layout_height="match_parent"
android:text="硬座" />
<TextView
android:id="@+id/tiket_listview_rz"
android:layout_weight="1"
android:layout_width="0dp"
android:singleLine="true"
android:textColor="@color/red"
android:layout_height="match_parent"
android:text="软座" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:id="@+id/tiket_listview_date"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:text="日期:" />
<TextView
android:id="@+id/tiket_listview_remark"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:paddingLeft="10dp"
android:text="备注:" />
</LinearLayout>
<TextView
android:id="@+id/tiket_listview_info"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="(以上信息仅供参考,请以车站为准)" />