| | |
| | | package com.weikou.beibeivideo.util.ad; |
| | | |
| | | import android.content.Context; |
| | | import android.util.Log; |
| | | |
| | | import com.bytedance.sdk.openadsdk.TTAdConfig; |
| | | import com.bytedance.sdk.openadsdk.TTAdConstant; |
| | |
| | | */ |
| | | public class TTAdManagerHolder { |
| | | |
| | | private static final String TAG = "TTAdManagerHolder"; |
| | | private static boolean sInit; |
| | | |
| | | |
| | | public static TTAdManager get() { |
| | | public static TTAdManager get() throws Exception{ |
| | | if (!sInit) { |
| | | throw new RuntimeException("TTAdSdk is not init, please check."); |
| | | throw new Exception("TTAdSdk is not init, please check."); |
| | | } |
| | | return TTAdSdk.getAdManager(); |
| | | } |
| | |
| | | private static void doInit(Context context) { |
| | | if (!sInit) { |
| | | try { |
| | | TTAdSdk.init(context, buildConfig(context)); |
| | | sInit = true; |
| | | TTAdSdk.init(context, buildConfig(context), new TTAdSdk.InitCallback() { |
| | | @Override |
| | | public void success() { |
| | | Log.i(TAG, "TTAdSdk初始化成功"); |
| | | sInit = true; |
| | | } |
| | | |
| | | @Override |
| | | public void fail(int i, String s) { |
| | | Log.e(TAG, "TTAdSdk初始化失败:"+s); |
| | | sInit = false; |
| | | } |
| | | }); |
| | | |
| | | } catch (Exception e) { |
| | | |
| | | } |