标签:des android style http io ar os 使用 sp
public class MainActivity extends Activity { private static final int THUMB_SIZE = 150; private static final String SDCARD_ROOT = Environment.getExternalStorageDirectory().getAbsolutePath(); private static final String APP_ID = "wx1b1ed04625409aa7"; private static final String tag = "MainActivity"; IWXAPI api = null; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); api = WXAPIFactory.createWXAPI(this, APP_ID, true); api.registerApp(APP_ID); sendImg(); } private void sendImg() { String imagePath = SDCARD_ROOT + "/test.png"; WXImageObject imgObj = new WXImageObject(); imgObj.setImagePath(imagePath); WXMediaMessage msg = new WXMediaMessage(); msg.mediaObject = imgObj; msg.description="图片描述"; Bitmap bmp = BitmapFactory.decodeFile(imagePath); Bitmap thumbBmp = Bitmap.createScaledBitmap(bmp, THUMB_SIZE, THUMB_SIZE, true); bmp.recycle(); msg.thumbData = Util.bmpToByteArray(thumbBmp, true); msg.title="abc-title"; SendMessageToWX.Req req = new SendMessageToWX.Req(); req.transaction = "img"+String.valueOf(System.currentTimeMillis()); req.message = msg; req.scene = SendMessageToWX.Req.WXSceneTimeline; api.sendReq(req); } }
findViewById(R.id.send_webpage).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { MMAlert.showAlert(SendToWXActivity.this, getString(R.string.send_webpage), SendToWXActivity.this.getResources().getStringArray(R.array.send_webpage_item), null, new MMAlert.OnAlertSelectId(){ @Override public void onClick(int whichButton) { switch(whichButton){ case MMAlertSelect1: WXWebpageObject webpage = new WXWebpageObject(); webpage.webpageUrl = "http://www.baidu.com"; WXMediaMessage msg = new WXMediaMessage(webpage); msg.title = "WebPage Title WebPage Title WebPage Title WebPage Title WebPage Title WebPage Title WebPage Title WebPage Title WebPage Title Very Long Very Long Very Long Very Long Very Long Very Long Very Long Very Long Very Long Very Long"; msg.description = "WebPage Description WebPage Description WebPage Description WebPage Description WebPage Description WebPage Description WebPage Description WebPage Description WebPage Description Very Long Very Long Very Long Very Long Very Long Very Long Very Long"; Bitmap thumb = BitmapFactory.decodeResource(getResources(), R.drawable.send_music_thumb); msg.thumbData = Util.bmpToByteArray(thumb, true); SendMessageToWX.Req req = new SendMessageToWX.Req(); req.transaction = buildTransaction("webpage"); req.message = msg; req.scene = isTimelineCb.isChecked() ? SendMessageToWX.Req.WXSceneTimeline : SendMessageToWX.Req.WXSceneSession; api.sendReq(req); finish(); break; default: break; } } }); } });
标签:des android style http io ar os 使用 sp
原文地址:http://www.cnblogs.com/xgjblog/p/4152815.html