1:羽声新版本

This commit is contained in:
2025-10-24 17:55:15 +08:00
parent a809b02ebb
commit 529aae1fcf
821 changed files with 29411 additions and 0 deletions

View File

@@ -0,0 +1,58 @@
package com.xscm.moduleutil.utils;
import android.content.Context;
import android.content.Intent;
import android.os.Build;
import com.xscm.moduleutil.service.IMConnectionService;
public class IMServiceManager {
private static IMServiceManager instance;
private boolean isServiceStarted = false;
private IMServiceManager() {
}
public static synchronized IMServiceManager getInstance() {
if (instance == null) {
instance = new IMServiceManager();
}
return instance;
}
public void startIMService(Context context) {
if (isServiceStarted) {
return;
}
Intent serviceIntent = new Intent(context, IMConnectionService.class);
try {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
context.startForegroundService(serviceIntent);
} else {
context.startService(serviceIntent);
}
isServiceStarted = true;
} catch (Exception e) {
e.printStackTrace();
}
}
public void stopIMService(Context context) {
if (!isServiceStarted) {
return;
}
Intent serviceIntent = new Intent(context, IMConnectionService.class);
try {
context.stopService(serviceIntent);
isServiceStarted = false;
} catch (Exception e) {
e.printStackTrace();
}
}
public boolean isServiceStarted() {
return isServiceStarted;
}
}