发表微博(个人记录)

 
1  Thread thread = new Thread(new UpdateStatusThread());
2 thread.start();
 
   
 1  // 发表微博
2 class UpdateStatusThread
3 implements Runnable {
4 public void run() {
5 int what = -1;
6 Status status = null;
7 weibo.setToken(accessToken, accessSecret);
8 try {
9 String msg = content.getText().toString();
10 // if (msg.getBytes().length != msg.length()) {
11 // msg = URLEncoder.encode(msg, "UTF-8");
12 byte[] content = getBitmapByte(bitmap);
13 ImageItem pic = new ImageItem("pic", content);
14 status = weibo.uploadStatus(msg, pic);
15 System.out.println(status);
16 // }
17 if (status != null) {
18 what = 1;
19 }
20 }
21 catch (Exception e) {
22 e.printStackTrace();
23 Log.e("WeiboPub", e.getMessage());
24 }
25 handle.sendEmptyMessage(what);
26 }
27 }
28
29 Handler handle = new Handler() {
30 @Override
31 public void handleMessage(Message msg) {
32 if (msg.what > 0) {
33 Toast.makeText(mContext, "分享成功", Toast.LENGTH_SHORT).show();
34 progress.setVisibility(View.GONE);
35 }
36 else {
37
38 Intent intent = new Intent();
39 intent.setClass(SharePage.this, WeiboOauthActvity.class);
40 Toast.makeText(mContext, "分享失败", Toast.LENGTH_SHORT).show();
41 }
42 }
43 };


  

你可能感兴趣的:(微博)