Bläddra i källkod

异步上传优化

guilin 1 månad sedan
förälder
incheckning
0c916bf05d

+ 3 - 0
app/src/main/java/com/fxy/main/MainActivity.java

@@ -122,6 +122,9 @@ public class MainActivity extends BaseActivity implements BadgeDismissListener,
         receiver = new DeviceStatusReceiver();
         // 创建 IntentFilter
         filter = new IntentFilter(Intent.ACTION_BATTERY_CHANGED);
+        filter.addAction(Intent.ACTION_BATTERY_CHANGED);
+        filter.addAction(Intent.ACTION_SCREEN_OFF);
+        filter.addAction(Intent.ACTION_SCREEN_OFF);
         // 注册 BroadcastReceiver
         registerReceiver(receiver, filter);
     }

+ 1 - 2
app/src/main/java/com/fxy/utils/UploadUtils.java

@@ -32,7 +32,7 @@ public class UploadUtils {
     }
     public static long getCurrentTime(){
         Calendar calendar = Calendar.getInstance();
-        calendar.set(Calendar.MILLISECOND, 0);
+
         return calendar.getTimeInMillis();
     }
 
@@ -46,7 +46,6 @@ public class UploadUtils {
     public static long calculateDifferenceInSeconds(long timestamp1, long timestamp2) {
         // 计算两个时间戳之间的差异(毫秒)
         long differenceInMillis = Math.abs(timestamp1 - timestamp2);
-
         // 将差异转换为秒
         return differenceInMillis / 1000;
     }