From 89e0f6ddd29ad4fb5947bfcea396ad4b55a6621f Mon Sep 17 00:00:00 2001 From: mac <user@users-MacBook-Pro.local> Date: 星期五, 14 六月 2024 11:08:00 +0800 Subject: [PATCH] 2024年06月14日11:07:49 --- app/src/main/java/com/hdl/photovoltaic/uni/HDLUniMPSDKManager.java | 52 +++++++++++++++++++++++++++++++++++++++++++++++----- 1 files changed, 47 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/com/hdl/photovoltaic/uni/HDLUniMPSDKManager.java b/app/src/main/java/com/hdl/photovoltaic/uni/HDLUniMPSDKManager.java index b120252..626e270 100644 --- a/app/src/main/java/com/hdl/photovoltaic/uni/HDLUniMPSDKManager.java +++ b/app/src/main/java/com/hdl/photovoltaic/uni/HDLUniMPSDKManager.java @@ -3,6 +3,7 @@ import android.app.Application; import android.content.Context; import android.os.Environment; +import android.os.SystemClock; import android.text.TextUtils; @@ -98,7 +99,8 @@ /** * 鐩戝惉鐩稿叧鍥炶皟 */ - private void registerCallBack() {DCUniMPSDK.getInstance(); + private void registerCallBack() { + DCUniMPSDK.getInstance(); //1.璁剧疆灏忕▼搴忚鍏抽棴浜嬩欢鐩戝惉 DCUniMPSDK.getInstance().setUniMPOnCloseCallBack(new IUniMPOnCloseCallBack() { @Override @@ -131,6 +133,8 @@ HdlLogLogic.print("鏀跺埌灏忕▼搴忛�氱煡 event=" + event); //鏆傛椂閫氳繃杩欎釜澶勭悊灏忕▼搴忓悓鏃跺鏉$浉鍚岀殑璇锋眰 if (data == null) { + HdlLogLogic.print("鏀跺埌灏忕▼搴忛�氱煡,data鏁版嵁涓簄ull銆�", true); + return; } // String key= MD5Utils.getMd5(event+data.toString()); @@ -151,6 +155,8 @@ //闄や簡缁熶竴澶勭悊锛屽墿浣欏叾瀹冪壒瀹氬満鏅殑浜嬩欢閫氱煡 if (onOtherUniMPEventCallBack != null) { onOtherUniMPEventCallBack.onOtherUniMPEventReceive(appid, event, data, callback); + } else { + HdlLogLogic.print("鏀跺埌灏忕▼搴忛�氱煡,鍥炶皟浜嬩欢涓簄ull,鏃犳硶鍥炶皟浜嬩欢骞舵墽琛屼笟鍔¢�昏緫--->event=" + event + "\r\n" + "data=" + data, true); } } } @@ -259,6 +265,41 @@ * @param jsonObject 闄勫姞鏁版嵁 * @param callBack 鐩戝惉灏忕▼搴廜therUniMPEvent浜嬩欢 */ + public void openUniMPDelay(String uniAppId, String path, JSONObject jsonObject, IOnOtherUniMPEventCallBack callBack) { + if (TextUtils.isEmpty(uniAppId)) { + HdlThreadLogic.toast(mContext, "uni Id null"); + HdlLogLogic.print("灏忕▼搴廔D 涓嶈兘涓虹┖"); + return; + } + try { + setOnOtherUniMPEventCallBack(callBack); + uniMP = null; + if (TextUtils.isEmpty(path)) { + uniMP = DCUniMPSDK.getInstance().openUniMP(mContext, uniAppId); + } else { + UniMPOpenConfiguration uniMPOpenConfiguration = new UniMPOpenConfiguration(); + uniMPOpenConfiguration.path = path; + uniMPOpenConfiguration.extraData = jsonObject; + uniMPOpenConfiguration.splashClass=MySplashView.class; + uniMP = DCUniMPSDK.getInstance().openUniMP(mContext, uniAppId, uniMPOpenConfiguration); + } + //android14鏈変簺璁惧鏈夐棶棰橈紝闇�瑕佺瓑寰� + if (android.os.Build.VERSION.SDK_INT >= 34) { + if (TextUtils.isEmpty(mCurrentAppId)) { + //绗竴娆$敤瑕佷紤鐪� + SystemClock.sleep(1000); + } + } + mCurrentAppId = uniAppId;//璁板綍褰撳墠灏忕▼搴� + mUniMPCaches.put(uniMP.getAppid(), uniMP); + } catch (Exception e) { + e.printStackTrace(); + HdlThreadLogic.toast(HDLApp.getInstance(), R.string.uni_open_error); +// initDCUniMPSDK(HDLApp.getInstance()); + HdlLogLogic.print("鎵撳紑澶辫触===" + e.getMessage()); + } + } + public void openUniMP(String uniAppId, String path, JSONObject jsonObject, IOnOtherUniMPEventCallBack callBack) { if (TextUtils.isEmpty(uniAppId)) { HdlThreadLogic.toast(mContext, "uni Id null"); @@ -274,6 +315,7 @@ UniMPOpenConfiguration uniMPOpenConfiguration = new UniMPOpenConfiguration(); uniMPOpenConfiguration.path = path; uniMPOpenConfiguration.extraData = jsonObject; + uniMPOpenConfiguration.splashClass=MySplashView.class; uniMP = DCUniMPSDK.getInstance().openUniMP(mContext, uniAppId, uniMPOpenConfiguration); } mCurrentAppId = uniAppId;//璁板綍褰撳墠灏忕▼搴� @@ -281,7 +323,7 @@ } catch (Exception e) { e.printStackTrace(); HdlThreadLogic.toast(HDLApp.getInstance(), R.string.uni_open_error); - initDCUniMPSDK(HDLApp.getInstance()); +// initDCUniMPSDK(HDLApp.getInstance()); HdlLogLogic.print("鎵撳紑澶辫触===" + e.getMessage()); } } @@ -353,12 +395,12 @@ if (mUniMPCaches.containsKey(uniAppId)) { if (mUniMPCaches.get(uniAppId) != null) { mUniMPCaches.get(uniAppId).sendUniMPEvent(topic, data); - HdlLogLogic.print("鍙戦�侀�氱煡鎴愬姛锛歟vent锛�" + topic + " data锛�" + new Gson().toJson(data)); + HdlLogLogic.print("Android--->閫氱煡---uni--->涓婚:" + topic + "--->鍙戦�佹暟鎹�:" + new Gson().toJson(data)); } else { - HdlLogLogic.print("鍙戦�佸け璐ワ紝灏忕▼搴忓璞′负绌猴細" + uniAppId); + HdlLogLogic.print("Android--->閫氱煡---uni--->澶辫触--->灏忕▼搴忓璞′负绌�:" + uniAppId); } } else { - HdlLogLogic.print("鍙戦�佸け璐ワ紝鎵句笉鍒板搴旂殑灏忕▼搴忥細" + uniAppId); + HdlLogLogic.print("Android--->閫氱煡---uni--->澶辫触--->灏忕▼搴忓璞′负绌�:" + uniAppId); } } -- Gitblit v1.8.0