更新时间:2022-03-21 GMT+08:00
分享

初始化

接口描述

该接口用于获取ShareServiceController 单例对象。

注意事项

需在create方法调用之后使用才能获得对象,否则返回null。

方法定义

/**
     * 获取接口单例对象
     * @param context 应用上下文
     * @param appInfo app相关信息
     * @param iShareEventHandler 上报事件通知函数
     */
    public static ShareServiceController getInstance();

参数描述

无。

示例代码

    ShareServiceController instance = ShareServiceController.getInstance();

接口描述

该接口用于初始化SDK,进行一些环境准备工作,调用其他接口之前必须先调用这个接口,只需要调用一次,建议放在Application的onCreate里。

注意事项

属于ShareServiceController类的静态方法,是调用SDK其它接口的前置条件。

方法定义

/**
     * 初始化接口
     * @param context 应用上下文
     * @param appInfo app相关信息
     * @param iShareEventHandler 上报事件通知函数
     */
    public static IShareServiceController create(Context context, AppInfo appInfo, IShareEventHandler iShareEventHandler);

参数描述

参数

是否必须

类型

描述

context

Context

应用上下文,建议使用getApplicationContext()

appInfo

AppInfo

app相关信息

appId

String

appId 建议取值企业域名+应用名 长度<=128

exePath

String

应用执行路径 长<=度128

logInfo

LogInfo

日志配置(可选,null则使用默认日志路径 /sdcard/Android/data/{appName}/files/Documents/)

iShareEventHandler

IShareEventHandler

注册上报事件通知函数类

示例代码

LogInfo logInfo = new LogInfo(path, LogLevel.DEBUG, true);
AppInfo appInfo = new AppInfo("appId", "log");
appInfo.setLogInfo(logInfo);
// 配置默认日志
IShareServiceController shareServiceController = ShareServiceController.create (this, appInfo, new IShareServiceController.IShareEventHandler() {
                    @Override
                    public void onRemoteServiceStatusChangedNotify(RemoteServiceStatus remoteServiceStatus) {
                    }
                    @Override
                    public void onShareStatusChangedNotify(ShareStatus shareStatus, int i) {
                    }
                });
返回值IShareServiceController为SDK对外提供的所有方法的interface。LogInfo参数建议总是传入,以便查看初始化日志。
分享:

    相关文档

    相关产品