-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathURL.txt
More file actions
40 lines (38 loc) · 1.96 KB
/
Copy pathURL.txt
File metadata and controls
40 lines (38 loc) · 1.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
new Thread(new Runnable() {
@Override
public void run() {
try {
URL url = new url("http://api.map.baidu.com/geodata/v3/poi/create");
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setDoOutput(true);
connection.setDoInput(true);
connection.setRequestProperty("Charset", "UTF-8");
connection.setRequestProperty("Connection", "Keep-Alive");
connection.setRequestMethod("POST");
connection.connect();
OutputStream outputStream = connection.getOutputStream();
outputStream.write("latitude=29.000".getBytes());
outputStream.write("&longitude=109.000".getBytes());
outputStream.write("&coord_type=3".getBytes());
outputStream.write("&longitude=109.000".getBytes());
outputStream.write("&geotable_id=101411".getBytes());
outputStream.write("&geotype=1".getBytes());
outputStream.write("&is_published=1".getBytes());
outputStream.write("&ak=eUNQyGGTfwphiqMMFag8Bx8N".getBytes());
outputStream.flush();
outputStream.close();
InputStream reader = connection.getInputStream();
byte[] b = new byte[200];
reader.read(b);
Log.i("tag:net", "±àÂë:"+connection.getContentEncoding());
reader.close();
Message message = new Message();
message.obj = b;
handler.sendMessage(message);
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
}).start();