ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
**1.申请产品密钥(Applying for a Product key)** **MHSDK** 首先需要向商务申请精简版、基础或者高级版的产品密钥,然后将密钥集成到项目中方可使用。 **MHSDK** first needs to apply for the product key of lite, basic or advanced version from the business, and then integrate the key into the project side for use. ***** **2.类库导入(The class library to import)** 将MHUI的文件夹拷贝到Android工程根目录, MHSDK目前支持、armv7,armv8版本,defaultConfig配置节点中添加(根据自身项目需求来设置): Copy the MHUI folder to the Android project root directory, MHSDK currently supports, armV7, ARMV8 version, defaultConfig config node added (according to their own project needs to set) : ``` ndk { abiFilters "armeabi-v7a","arm64-v8a" } ``` 引入mhui模块 Introduce the mhui module ``` implementation project(':mhui') ``` ***** **3.初始化SDK(To initialize the SDK )** ~~~ MHSDK.init(this,"您的授权密钥");//建议在Application子类的onCreate方法中初始化SDK ~~~ ~~~ MHSDK.init(this,"Your authorization key"); // It is recommended to initialize the SDK in the onCreate method of the Application subclass ~~~ ***** **4.添加美狐UI组件(Add the MHSDK UI component)** 在布局文件中添加美狐的UI组件 Add the UI component of the MHSDK to the layout file ``` <com.meihu.beauty.views.MeiHuBeautyControl android:layout_width="match_parent" android:layout_height="match_parent"/> ``` ***** **5.在集成了美狐UI组件的Activity中初始化(Class in an Activity that integrates the MHSDK UI component)** ~~~ //初始化(initialize) MhDataManager.getInstance().create(this.getApplicationContext()); ~~~ **6.在直播SDK的渲染方法 调用美狐SDK的渲染方法 返回新生成的纹理ID(The render method in the live SDK calls the render method in the MHSDK to return the newly generated texture ID )** ~~~ int textureId = MhDataManager.getInstance().render(texture, width, height); return textureId; //修改MhDataManager#render public int render(int texture, int width, int height) {         if (mMhManager != null) {             try {                 texture = mMhManager.renderxxx(...);             } catch (Exception e) {                 e.printStackTrace();             }         }else{            Log.e(TAG, "render: error");         }         return texture;     } // 阿里云:render18(...) // 慕色短视频,七牛短视频:render3(...) // 网易,render4(...) // 声网:render16(...) // 七牛直播,融云:render5(...) // 即构:render6(...) // 金山:render7(...) // 声网视频通话(前置摄像头):render10(...) // 声网视频通话(后置摄像头):render11(...) // 腾讯直播:render12(...) // 三体:render14(...) ~~~ ~~~ int textureId = MhDataManager.getInstance().render(texture, width, height); return textureId; //modification MhDataManager#render public int render(int texture, int width, int height) {         if (mMhManager != null) {             try {                 texture = mMhManager.renderxxx(...);             } catch (Exception e) {                 e.printStackTrace();             }         }else{            Log.e(TAG, "render: error");         }         return texture;     } // Alibaba Cloub:render18(...) // Qiniu Cloud:render3(...) // Netease,render4(...) // Agora:render16(...) // Qiniu Cloud,RongCloud:render5(...) // ZEGO:render6(...) // Kingsoft:render7(...) // Agora(front-facing camera ):render10(...) // Agora(rear camera):render11(...) // Tencent live:render12(...) // santiyun:render14(...) ~~~ ***** **7.如何您使用了MhDataManager结束时销毁防止内存泄漏(How do you use MhDataManager at the end of destruction to prevent memory leaks )** ~~~ MhDataManager.getInstance().release(); ~~~ ***** **8.切换SDK的语言** MHSDK目前支持中文和英语两种语言 MHSDK currently supports both Chinese and English 可以通过在Application和Activity中修改context中的语言配置来切换语言,由于Appliction和Activity中获取的context是不同对象 所以都需要修改 You can switch languages by changing the language configuration of the context in Application and Activity, which need to be changed because the context obtained in Application and Activity are different objects 示例例代码如下: Example code is as follows: ~~~ Resources resources = getResources(); Configuration config = resources.getConfiguration(); DisplayMetrics dm = resources.getDisplayMetrics(); config.locale = Locale.ENGLISH; resources.updateConfiguration(config, dm); ~~~