為何我的一閃就返回了,并沒有分享出去
protected void onCreate(Bundle savedInstanceState) {
? ?super.onCreate(savedInstanceState);
? ?setContentView(R.layout.activity_send_to_wx);
? ?api = WXAPIFactory.createWXAPI(this, MainActivity.WX_APP_ID, false);
? ?api.registerApp(MainActivity.WX_APP_ID);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
? ?// Inflate the menu; this adds items to the action bar if it is present.
? ?getMenuInflater().inflate(R.menu.menu_send_to_wx, menu);
? ?return true;
}
private String buildTransaction(final String type) {
? ?return (type == null) ? String.valueOf(System.currentTimeMillis()) : type + System.currentTimeMillis();
}
public void send_text_to_wx(View view) {
? ?WXTextObject textObject = new WXTextObject();
? ?textObject.text = "來自測試";
? ?WXMediaMessage msg = new WXMediaMessage();
? ?msg.title = "測試Title";
? ?msg.mediaObject = textObject;
? ?msg.description = "藐視";
? ?SendMessageToWX.Req req = new SendMessageToWX.Req();
? ?req.transaction = buildTransaction("text");
? ?req.message = msg;
? ?req.scene = SendMessageToWX.Req.WXSceneSession;
? ?api.sendReq(req);
? ?finish();
}
2015-08-17
分享閃回是app簽名的問題,你直接用Eclipse run運行用的是debug.keystore 和申請時填寫的應用簽名不一樣,所以出問題。用正式簽名打包安裝到真機上就好了