发布网友 发布时间:2022-04-24 02:09
共1个回答
热心网友 时间:2023-10-21 02:02
你好。
微信SDK分享签名打包,你试下如下代码:
private Button btn_share;
public static final String WX_APP_ID = "wxc85b9dbef61b3fe4";
private IWXAPI api;
private String text="testssss";
@Override
public void onCreate(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() {
@Override
public void onClick(View v) {
api.registerApp(WX_APP_ID);
// 初始化一个WXTextObject对象
WXTextObjecttextObj = newWXTextObject();
textObj.text = text;
// 用WXTextObject对象初始化一个WXMediaMessage对象
WXMediaMessagemsg = newWXMediaMessage();
msg.mediaObject = textObj;
// 发送文本类型的消息时,title字段不起作用
msg.title = "Will be ignored";
msg.description = "sdddd";
// 构造一个Req
SendMessageToWX.Reqreq = newSendMessageToWX.Req();
req.transaction = buildTransaction("text"); // transaction字段用于唯一标识一个请求
req.message = msg;
//req.scene = SendMessageToWX.Req.WXSceneTimeline ;
// 调用api接口发送数据到微信
api.sendReq(req);
finish();
}
});
}
private StringbuildTransaction(finalString type) {
return (type == null) ? String.valueOf(System.currentTimeMillis())
:type + System.currentTimeMillis();
}
热心网友 时间:2023-11-12 02:59
你好。
微信SDK分享签名打包,你试下如下代码:
private Button btn_share;
public static final String WX_APP_ID = "wxc85b9dbef61b3fe4";
private IWXAPI api;
private String text="testssss";
@Override
public void onCreate(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() {
@Override
public void onClick(View v) {
api.registerApp(WX_APP_ID);
// 初始化一个WXTextObject对象
WXTextObjecttextObj = newWXTextObject();
textObj.text = text;
// 用WXTextObject对象初始化一个WXMediaMessage对象
WXMediaMessagemsg = newWXMediaMessage();
msg.mediaObject = textObj;
// 发送文本类型的消息时,title字段不起作用
msg.title = "Will be ignored";
msg.description = "sdddd";
// 构造一个Req
SendMessageToWX.Reqreq = newSendMessageToWX.Req();
req.transaction = buildTransaction("text"); // transaction字段用于唯一标识一个请求
req.message = msg;
//req.scene = SendMessageToWX.Req.WXSceneTimeline ;
// 调用api接口发送数据到微信
api.sendReq(req);
finish();
}
});
}
private StringbuildTransaction(finalString type) {
return (type == null) ? String.valueOf(System.currentTimeMillis())
:type + System.currentTimeMillis();
}
热心网友 时间:2023-10-21 02:02
你好。
微信SDK分享签名打包,你试下如下代码:
private Button btn_share;
public static final String WX_APP_ID = "wxc85b9dbef61b3fe4";
private IWXAPI api;
private String text="testssss";
@Override
public void onCreate(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() {
@Override
public void onClick(View v) {
api.registerApp(WX_APP_ID);
// 初始化一个WXTextObject对象
WXTextObjecttextObj = newWXTextObject();
textObj.text = text;
// 用WXTextObject对象初始化一个WXMediaMessage对象
WXMediaMessagemsg = newWXMediaMessage();
msg.mediaObject = textObj;
// 发送文本类型的消息时,title字段不起作用
msg.title = "Will be ignored";
msg.description = "sdddd";
// 构造一个Req
SendMessageToWX.Reqreq = newSendMessageToWX.Req();
req.transaction = buildTransaction("text"); // transaction字段用于唯一标识一个请求
req.message = msg;
//req.scene = SendMessageToWX.Req.WXSceneTimeline ;
// 调用api接口发送数据到微信
api.sendReq(req);
finish();
}
});
}
private StringbuildTransaction(finalString type) {
return (type == null) ? String.valueOf(System.currentTimeMillis())
:type + System.currentTimeMillis();
}
热心网友 时间:2023-10-21 02:02
你好。
微信SDK分享签名打包,你试下如下代码:
private Button btn_share;
public static final String WX_APP_ID = "wxc85b9dbef61b3fe4";
private IWXAPI api;
private String text="testssss";
@Override
public void onCreate(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() {
@Override
public void onClick(View v) {
api.registerApp(WX_APP_ID);
// 初始化一个WXTextObject对象
WXTextObjecttextObj = newWXTextObject();
textObj.text = text;
// 用WXTextObject对象初始化一个WXMediaMessage对象
WXMediaMessagemsg = newWXMediaMessage();
msg.mediaObject = textObj;
// 发送文本类型的消息时,title字段不起作用
msg.title = "Will be ignored";
msg.description = "sdddd";
// 构造一个Req
SendMessageToWX.Reqreq = newSendMessageToWX.Req();
req.transaction = buildTransaction("text"); // transaction字段用于唯一标识一个请求
req.message = msg;
//req.scene = SendMessageToWX.Req.WXSceneTimeline ;
// 调用api接口发送数据到微信
api.sendReq(req);
finish();
}
});
}
private StringbuildTransaction(finalString type) {
return (type == null) ? String.valueOf(System.currentTimeMillis())
:type + System.currentTimeMillis();
}