微信開放平臺 - Android調用微信分享不顯示
問題描述
點擊分享功能之后就一直停在空白頁面,微信界面也沒有顯示
代碼如下:
case R.id.action_share_wechat:api = WXAPIFactory.createWXAPI(this, APP_ID, false);api.registerApp(APP_ID);WXWebpageObject webpage = new WXWebpageObject();webpage.webpageUrl = 'www.dubai.com';WXMediaMessage msg = new WXMediaMessage(webpage);msg.title = '****';msg.description = '****';Bitmap bmp = BitmapFactory.decodeResource(getResources(), R.drawable.pic_cbox);Bitmap thumbBmp = Bitmap.createScaledBitmap(bmp,120,120, true);bmp.recycle();msg.setThumbImage(thumbBmp);SendMessageToWX.Req req = new SendMessageToWX.Req();req.transaction = type + System.currentTimeMillis();req.message = msg;req.scene = SendMessageToWX.Req.WXSceneTimeline;api.sendReq(req);break;
public class WXEntryActivity extends AppCompatActivity implements IWXAPIEventHandler { private static final String APP_ID = 'wxf********'; private IWXAPI api; @Override protected void onCreate(@Nullable Bundle savedInstanceState) {super.onCreate(savedInstanceState);api = WXAPIFactory.createWXAPI(this, APP_ID,false);api.registerApp(APP_ID);api.handleIntent(getIntent(),this); } @Override public void onReq(BaseReq baseReq) { } @Override public void onResp(BaseResp baseResp) { }}
日志如下:
08-20 17:35:20.437 32132-32132/net.muxi.huashiapp V/MicroMsg.SDK.WXApiImplV10.ActivityLifecycleCb: net.muxi.huashiapp.webview.WebViewActivity onActivityPaused08-20 17:35:21.237 32132-32132/net.muxi.huashiapp V/MicroMsg.SDK.WXApiImplV10.ActivityLifecycleCb: WXStat trigger onBackground08-20 17:35:21.327 32132-32350/net.muxi.huashiapp D/dalvikvm: GC_FOR_ALLOC freed 915K, 26% free 19464K/26244K, paused 18ms, total 18ms08-20 17:35:21.857 32132-32132/net.muxi.huashiapp D/CrashReport: >>> net.muxi.huashiapp.wxapi.WXEntryActivity onResumed <<<08-20 17:35:21.857 32132-32132/net.muxi.huashiapp I/CrashReport: [session] launch app one times (app in background 1 seconds and over 0 seconds)08-20 17:35:21.857 32132-32132/net.muxi.huashiapp D/CrashReport: delay 0 task com.tencent.bugly.crashreport.biz.a$a08-20 17:35:21.857 32132-32132/net.muxi.huashiapp V/MicroMsg.SDK.WXApiImplV10.ActivityLifecycleCb: net.muxi.huashiapp.wxapi.WXEntryActivity onActivityResumed08-20 17:35:21.867 32132-32171/net.muxi.huashiapp D/CrashReport: record userinfo08-20 17:35:22.057 32132-32171/net.muxi.huashiapp D/CrashReport: [db] insert t_ui success08-20 17:35:22.057 32132-32171/net.muxi.huashiapp D/CrashReport: insert t_ui success! 1708-20 17:35:22.667 32132-32132/net.muxi.huashiapp V/MicroMsg.SDK.WXApiImplV10.ActivityLifecycleCb: WXStat trigger onForeground
問題解答
回答1:微信分享要打包簽名才能使用,如果分享不成功,再次安裝需要清理微信數據才能分享
回答2:樓上說得對,另外那個WXEntryActivity必須放在你APP包名下的wxapi包下
相關文章:
1. 老師您的微信號是多少?2. javascript - 微信網頁開發從菜單進入頁面后,按返回鍵沒有關閉瀏覽器而是刷新當前頁面,求解決?3. node.js - nodejs開發中常用的連接mysql的庫4. 在html文件的目錄下輸入代碼按回車后顯示這個,哪位大佬幫幫我 呀5. mysql - jdbc的問題6. mysql replace 死鎖7. 視頻文件不能播放,怎么辦?8. mysql - 分庫分表、分區、讀寫分離 這些都是用在什么場景下 ,會帶來哪些效率或者其他方面的好處9. windows7 ping不通虛擬機VMware上的linux(ubuntu)的ip10. mysql - 如何減少使用或者不用LEFT JOIN查詢?
