private final String APP_ID = "wxbd7d6g4h9a0f8f6f";//APPID是需要在微信官网上申请的https://open.weixin.qq.com
public void shareToWX(){ final IWXAPI api = WXAPIFactory.createWXAPI(getApplicationContext(),APP_ID,true); api.registerApp(APP_ID);//创建API WXWebpageObject webpage=new WXWebpageObject();//定义一个webpage webpage.webpageUrl="https://www.baidu.com/";//要分享的网页URL WXMediaMessage msg = new WXMediaMessage(webpage);//添加webpage msg.title="";//设置标题 msg.description="";//添加描述 SendMessageToWX.Req req = new SendMessageToWX.Req();//创建请求 req.transaction = buildTransaction("webpage"); req.message = msg; req.scene=SendMessageToWX.Req.WXSceneTimeline; api.sendReq(req);//调用接口发送请求 }