微信开放平台 - Android调用微信分享不显示
迷茫
迷茫 2017-04-17 17:39:59
0
2
818

点击分享功能之后就一直停在空白页面,微信界面也没有显示

代码如下:

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  onActivityPaused
08-20 17:35:21.237 32132-32132/net.muxi.huashiapp V/MicroMsg.SDK.WXApiImplV10.ActivityLifecycleCb: WXStat trigger onBackground
08-20 17:35:21.327 32132-32350/net.muxi.huashiapp D/dalvikvm: GC_FOR_ALLOC freed 915K, 26% free 19464K/26244K, paused 18ms, total 18ms
08-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$a
08-20 17:35:21.857 32132-32132/net.muxi.huashiapp V/MicroMsg.SDK.WXApiImplV10.ActivityLifecycleCb: net.muxi.huashiapp.wxapi.WXEntryActivity  onActivityResumed
08-20 17:35:21.867 32132-32171/net.muxi.huashiapp D/CrashReport: record userinfo
08-20 17:35:22.057 32132-32171/net.muxi.huashiapp D/CrashReport: [db] insert t_ui success
08-20 17:35:22.057 32132-32171/net.muxi.huashiapp D/CrashReport: insert t_ui success! 17
08-20 17:35:22.667 32132-32132/net.muxi.huashiapp V/MicroMsg.SDK.WXApiImplV10.ActivityLifecycleCb: WXStat trigger onForeground
迷茫
迷茫

业精于勤,荒于嬉;行成于思,毁于随。

Antworte allen(2)
PHPzhong

微信分享要打包签名才能使用,如果分享不成功,再次安装需要清理微信数据才能分享

伊谢尔伦

楼上说得对,另外那个WXEntryActivity必须放在你APP包名下的wxapi包下

Beliebte Tutorials
Mehr>
Neueste Downloads
Mehr>
Web-Effekte
Quellcode der Website
Website-Materialien
Frontend-Vorlage