|  |  | 
 |  |  |     private static final String TAG = "H2EngineSDK"; | 
 |  |  |     private static String APP_ID = ""; | 
 |  |  |  | 
 |  |  |     private static boolean PushEnable = true; | 
 |  |  |  | 
 |  |  |     public static void HandleUnityMessage(String json) | 
 |  |  |     { | 
 |  |  |         LogUtil.i(TAG, "收到Unity发来的信息: " + json); | 
 |  |  | 
 |  |  |                     break; | 
 |  |  |                 case CodeU2A.AssetCopy: | 
 |  |  |                     FileUtil.copyAssets(_activity); | 
 |  |  |                     break; | 
 |  |  |                 case CodeU2A.CopyOneAsset: | 
 |  |  |                     FileUtil.copy(_activity, _json.getString("fileName")); | 
 |  |  |                     break; | 
 |  |  |                 case CodeU2A.BatteryListenStart: | 
 |  |  |                     BatteryUtil.getInstance().start(_activity); | 
 |  |  | 
 |  |  |                 case CodeU2A.JPushRemoveLocalMessage: | 
 |  |  |                     removeNotification(_activity, _json.getInt("id")); | 
 |  |  |                     break; | 
 |  |  |                 case CodeU2A.SendRegistEvent: | 
 |  |  |                     JSPlatformUtil.getInstance().SendRegisterEvent(); | 
 |  |  |                     break; | 
 |  |  |             } | 
 |  |  |  | 
 |  |  |         } catch (JSONException e) | 
 |  |  | 
 |  |  |     public static void addLocalNotification(Activity activity, int id, String title, String content, | 
 |  |  |                                             long fireTime) | 
 |  |  |     { | 
 |  |  |         try | 
 |  |  |         if (PushEnable) | 
 |  |  |         { | 
 |  |  |             JPushLocalNotification ln = new JPushLocalNotification(); | 
 |  |  |             ln.setBuilderId(0);// 设置样式 | 
 |  |  |             ln.setNotificationId(id);// id | 
 |  |  |             ln.setTitle(title);// 标题 | 
 |  |  |             try | 
 |  |  |             { | 
 |  |  |                 JPushLocalNotification ln = new JPushLocalNotification(); | 
 |  |  |                 ln.setBuilderId(0);// 设置样式 | 
 |  |  |                 ln.setNotificationId(id);// id | 
 |  |  |                 ln.setTitle(title);// 标题 | 
 |  |  |  | 
 |  |  |             ln.setContent(content);// 内容 | 
 |  |  |             ln.setBroadcastTime(fireTime);// 等待时间 | 
 |  |  |             JPushInterface.addLocalNotification(activity, ln); | 
 |  |  |         } catch (Exception e) | 
 |  |  |         { | 
 |  |  |             e.printStackTrace(); | 
 |  |  |                 ln.setContent(content);// 内容 | 
 |  |  |                 ln.setBroadcastTime(fireTime);// 等待时间 | 
 |  |  |                 JPushInterface.addLocalNotification(activity, ln); | 
 |  |  |             } catch (Exception e) | 
 |  |  |             { | 
 |  |  |                 e.printStackTrace(); | 
 |  |  |             } | 
 |  |  |         } | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     public static void removeNotification(Activity activity, int id) | 
 |  |  |     { | 
 |  |  |         JPushInterface.removeLocalNotification(activity, id); | 
 |  |  |         if (PushEnable) | 
 |  |  |         { | 
 |  |  |             JPushInterface.removeLocalNotification(activity, id); | 
 |  |  |         } | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     public static void GetExternalStorage() | 
 |  |  | 
 |  |  |             return; | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |         PushEnable = activity.getPackageName().equals("com.lingleigame.shaonianqixiachuan"); | 
 |  |  |  | 
 |  |  |         new Thread(new Runnable() | 
 |  |  |         { | 
 |  |  |             @Override | 
 |  |  | 
 |  |  |                 UniversalUtil.sendMessageToUnity(_msgStruct); | 
 |  |  |  | 
 |  |  |                 // ------------------------------- 极光推送 ------------------------------- | 
 |  |  |                 JPushInterface.setDebugMode(true); | 
 |  |  |                 JPushInterface.init(activity); | 
 |  |  |  | 
 |  |  |                 final long _waitingTime = System.currentTimeMillis(); | 
 |  |  |  | 
 |  |  |                 while (true) | 
 |  |  |                 String _registrationID = "0"; | 
 |  |  |                 if (PushEnable) | 
 |  |  |                 { | 
 |  |  |                     // 等待获取极光registrationID | 
 |  |  |                     if (!JPushInterface.getRegistrationID(activity).equals("")) | 
 |  |  |                     { | 
 |  |  |                         break; | 
 |  |  |                     } | 
 |  |  |                     JPushInterface.setDebugMode(true); | 
 |  |  |                     JPushInterface.init(activity); | 
 |  |  |  | 
 |  |  |                     long _escapeTime = System.currentTimeMillis() - _waitingTime; | 
 |  |  |                     final long _waitingTime = System.currentTimeMillis(); | 
 |  |  |  | 
 |  |  |                     if (_escapeTime > 3000) | 
 |  |  |                     while (true) | 
 |  |  |                     { | 
 |  |  |                         LogUtil.w(TAG, "等待获取极光推送registrationID超时: 3秒"); | 
 |  |  |                         break; | 
 |  |  |                         // 等待获取极光registrationID | 
 |  |  |                         if (!JPushInterface.getRegistrationID(activity).equals("")) | 
 |  |  |                         { | 
 |  |  |                             _registrationID = JPushInterface.getRegistrationID(activity); | 
 |  |  |                             break; | 
 |  |  |                         } | 
 |  |  |  | 
 |  |  |                         long _escapeTime = System.currentTimeMillis() - _waitingTime; | 
 |  |  |  | 
 |  |  |                         if (_escapeTime > 3000) | 
 |  |  |                         { | 
 |  |  |                             LogUtil.w(TAG, "等待获取极光推送registrationID超时: 3秒"); | 
 |  |  |                             break; | 
 |  |  |                         } | 
 |  |  |                     } | 
 |  |  |                 } | 
 |  |  |  | 
 |  |  |                 _msgStruct.clear(); | 
 |  |  |                 _msgStruct.put("code", CodeA2U.PushClientID); | 
 |  |  |                 _msgStruct.put("clientID", JPushInterface.getRegistrationID(activity)); | 
 |  |  |                 _msgStruct.put("clientID", _registrationID); | 
 |  |  |                 UniversalUtil.sendMessageToUnity(_msgStruct); | 
 |  |  |  | 
 |  |  |                 _msgStruct.clear(); |