修改名称。

This commit is contained in:
2025-11-07 09:22:39 +08:00
parent d9cf55b053
commit a8dcfbb6a7
2203 changed files with 3 additions and 4 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;
}
}