Saturday, March 8, 2014

How micro-channel circle of friends while sharing (picture + text) Android version


The following are: micro-channel circle of friends to share pictures SDK code, but only share pictures, can not share text, images and text on how to share the same great God you seek advice
?!
 
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 = "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);
}
}
<-! Main posts under Banner (D4) -><-! Posts under the main text (D5) ->
Reply:
Try description of the members WXMediaMessage api.

- (NSString *) description [read, write, retain]
Describe the content

Note:
Length should not exceed 1K

msg.description = "You need to text";
Reply:
cited a floor ameyume reply:
Try description of the members WXMediaMessage api.

- (NSString *) description [read, write, retain]
Describe the content

Note:
Length should not exceed 1K

msg.description = "You need to text";

This seems to be IOS right? WXMediaMessage object and above, I also used the Well
Reply:
WXWebpageObject webpage = new WXWebpageObject ();
/ / Why do I need to fill url? micro-channel SDK Demo currently using does not support graphics sharing, using graphic sharing must turn into a URL to share, so they need to fill in a URL
webpage.webpageUrl = fenXiangUrl;

WXMediaMessage msg = new WXMediaMessage (webpage);
msg.title = content;
msg.description = content;

Operating picture msg.thumbData;


SendMessageToWX.Req req = new SendMessageToWX.Req ();
req.transaction = buildTransaction ("webpage");
req.message = msg;

req.scene = toCircle? SendMessageToWX.Req.WXSceneTimeline
: SendMessageToWX.Req.WXSceneSession;
boolean sendReq = api.sendReq (req);
It should be very detailed

Reply:
lulong1985 Thank you! really see the document more carefully than I am, of course, wanted to when I wanted to get more than I could have!
Later, the official demo I also found the following code
 
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;
}
}
});
}
});

Thank you anyway!
However, I am using the SDK Alliance, the Alliance integrates QQ space, SDK QQ, micro-channel, micro-channel circle of friends, Renren, Douban, etc. .., which includes sharing, login, comments and other features, personal feel also more convenient.

Lulong1985 you want to add to QQ friends!
Reply:
Thank Supreme sharing, very useful!

No comments:

Post a Comment