美文网首页
Umeng分享和微信支付注意事项

Umeng分享和微信支付注意事项

作者: TMAC_EAH | 来源:发表于2021-04-21 10:08 被阅读0次

1 清单文件注册

 <activity
            android:name="包名.wxapi.WXPayEntryActivity"
            android:configChanges="keyboardHidden|screenSize"
            android:exported="true"
            android:launchMode="singleTask"
            android:taskAffinity="包名"
            android:theme="@android:style/Theme.Translucent.NoTitleBar"
            tools:replace="android:configChanges" />
        <activity
            android:name="包名.wxapi.WXEntryActivity"
            android:configChanges="keyboardHidden|orientation|screenSize"
            android:exported="true"
            android:launchMode="singleTask"
            android:taskAffinity="包名"
            android:theme="@android:style/Theme.Translucent.NoTitleBar"
            tools:replace="android:configChanges" />

//============调整后============
// 不然会产生闪屏问题
//            android:launchMode="singleTask"
//            android:taskAffinity="包名"
   <activity
            android:name="包名.wxapi.WXPayEntryActivity"
            android:configChanges="keyboardHidden|orientation|screenSize"
            android:exported="true"
            android:theme="@android:style/Theme.Translucent.NoTitleBar"
            tools:replace="android:configChanges" />
        <activity
            android:name="包名.wxapi.WXEntryActivity"
            android:configChanges="keyboardHidden|orientation|screenSize"
            android:exported="true"
            android:theme="@android:style/Theme.Translucent.NoTitleBar"
            tools:replace="android:configChanges" />

2.调用super.onResp(xxx)

public class WXEntryActivity extends WXCallbackActivity implements IWXAPIEventHandler {
    @Override
    public void onResp(BaseResp resp) {
        super.onResp(resp); // 别忘了调用,否则分享的时候 透明界面不关闭,当集成微信支付的时候
        LogUtils.e(TAG, "微信onResp=[" + resp + "]");
    }

  /**
     * 从微信启动App
     *
     * @param baseReq
     */
    @Override
    public void onReq(BaseReq baseReq) {
        //获取开放标签传递的extinfo数据逻辑
        if (baseReq.getType() == ConstantsAPI.COMMAND_SHOWMESSAGE_FROM_WX && baseReq instanceof ShowMessageFromWX.Req) {
            ShowMessageFromWX.Req showReq = (ShowMessageFromWX.Req) baseReq;
            WXMediaMessage mediaMsg = showReq.message;
            String extInfo = mediaMsg.messageExt;
            //Handle...
            try {
                WxOpenApp wxOpenApp = new Gson().fromJson(extInfo, WxOpenApp.class);
                if (MainActivity.APP_ACTIVE) {
                    LogUtils.e(TAG, "微信启动app=[" + extInfo + "]");
                    //跳转到该圈子详情页
//                    CircleTrendActivity.start(this, wxOpenApp.data.id);
                    CircleDetailJumper.start(this, wxOpenApp.data.id, V4StatisticEvent.CircleDetailFrom.page_expertcircle_share);
                } else {
                    LogUtils.e(TAG, "应用已退出,微信启动app=[" + extInfo + "]");
                    JpushBean.openApp(this, wxOpenApp);
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
            LogUtils.e(TAG, "微信启动app=[" + extInfo + "]");
            finish();
        } else {
            super.onReq(baseReq); // 添加这行 =============
        }
    }
}

相关文章

网友评论

      本文标题:Umeng分享和微信支付注意事项

      本文链接:https://www.haomeiwen.com/subject/chualltx.html