古詩詞大全網 - 個性簽名 - 微信sdk分享如何簽名打包。

微信sdk分享如何簽名打包。

妳好。

微信SDK分享簽名包,妳試試下面這段代碼:

私按鈕btn _ share

公共靜態最終字符串WX _ APP _ ID = " wxc 85 b 9 dbef 61 B3 Fe 4 ";

私有IWXAPI api

私有字符串text = " testssss

@覆蓋

公共void on create(BundlesavedInstanceState){

super . oncreate(savedInstanceState);

setContentView(r . layout . main);

BTN _ share =(Button)findViewById(r . id . BTN _ share);

API = wxapifactory . createwxapi(this,WX_APP_ID,false);

BTN _ share . setonclicklistener(new OnClickListener(){

@覆蓋

公共void onClick(視圖v) {

API . register APP(WX _應用_ ID);

//初始化WXTextObject對象。

WXTextObjecttextObj = newWXTextObject();

textObj.text = text

//用WXTextObject對象初始化WXMediaMessage對象。

WXMediaMessagemsg = newWXMediaMessage();

msg . media object = text obj;

//發送文本類型的消息時,標題字段沒有作用。

msg.title = "將被忽略";

msg.description = " sdddd

//構造壹個請求

SendMessageToWX。Reqreq = newSendMessageToWX。req();

req . transaction = build transaction(" text ");//事務字段用於唯壹標識請求。

req.message = msg

//req.scene = SendMessageToWX。Req . WXSceneTimeline

//調用api接口向微信發送數據。

API . sendreq(req);

finish();

}

});

}

私有StringbuildTransaction(final string類型){

return (type == null)?string . value of(system . current time millis())

:type+system . current time millis();

}