其他(未完)

6. 互推相关

6.1 初始化

XYXNative.init();

6.2 获取互推数据

XYXNative.getConfig();

6.3 上报互推展示

XYXConfig config = XYXNative.getConfig();
ArrayList<XYXItem> list = config.getItemList();
if (list != null && list.size() > 0) {
    XYXItem item = list.get(0);
    config.exposureShow(item);
}

6.4 响应互推点击

XYXConfig config = XYXNative.getConfig();
ArrayList<XYXItem> list = config.getItemList();
if (list != null && list.size() > 0) {
    XYXItem item = list.get(0);
    config.handleClick(item);
}

7. 社交相关

7.1 初始化

SocialProxy.init()

7.2 登录及获取用户信息

SocialProxy.loginAndUpdateInfo(SocialDef.TYPE_WX,new SocialProxy.SocialCallBack() {
    @Override
    public void onResult(HashMap<String, String> map) {
        if(map.get("retCode").equalsIgnoreCase("1"))//获取用户信息成功
        {
            Log.i("skay","loginAndUpdateInfo  success  ");
            Log.i("skay","openId  is  "+map.get("openid"));
            Log.i("skay","nickname  is  "+map.get("nickname"));
            Log.i("skay","headimgUrl  is  "+map.get("headimgUrl"));
            Log.i("skay","sex  is  "+map.get("sex"));
        }else//登录失败/获取用户信息失败
        {
            Log.i("skay","loginAndUpdateInfo  fail   "+map.toString());
        }
    }
});

7.3 微信需引用微信模块

implementation 'com.libVigame.Social:WeChat:2.1.9'//改为最新版本

7.4 微信登录需添加 WXEntryActivity类(包名为 applicationID + ".wxapi")

package com.hw2.jgzsj2.wxapi;//包名为 applicationID + ".wxapi"

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;

import com.libSocial.WeChat.WeChatActivityHandler;

public class WXEntryActivity extends Activity {
    private WeChatActivityHandler weChatActivityHandler = null;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        weChatActivityHandler = new WeChatActivityHandler();
        weChatActivityHandler.onCreate(this);
        this.finish();
    }
    @Override
    protected void onNewIntent(Intent intent) {
        super.onNewIntent(intent);
        if (weChatActivityHandler != null) {
            weChatActivityHandler.onNewIntent(intent);
        }
    }
}

最后更新于