wjc
2025-04-28 a3d9e72e6e4f7ad6778e89bc05f2fe656e36dab7
app/src/main/java/com/hdl/photovoltaic/services/ForeService.java
@@ -11,6 +11,7 @@
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.pm.ServiceInfo;
import android.graphics.BitmapFactory;
import android.graphics.Color;
import android.os.Build;
@@ -38,18 +39,28 @@
 */
public class ForeService extends Service {
    final String TAG=ForeService.class.getName();
    final String TAG = ForeService.class.getName();
    @Override
    public IBinder onBind(Intent intent) {
        return null;
    }
    @SuppressLint("ForegroundServiceType")
    @Override
    public void onCreate() {
        super.onCreate();
        Log.d(TAG, "ForeService onCreate() 进程Id:"+android.os.Process.myPid() );
        startForeground(1, getNotification(getString(R.string.app_name), "Running"));
//        Log.d(TAG, "ForeService onCreate() 进程Id:" + android.os.Process.myPid());
//        try {
//            // Kotlin 示例
//            if (Build.VERSION.SDK_INT >= 34) {
//                startForeground(1, getNotification(getString(R.string.app_name), "Running"), ServiceInfo.FOREGROUND_SERVICE_TYPE_MEDIA_PLAYBACK);
//            } else {
//                startForeground(1, getNotification(getString(R.string.app_name), "Running"));
//            }
//        } catch (Exception e) {
//        }
    }
    @Override