导航菜单

页面标题

页面副标题

Biko v2.0.23 - ZegoScreenCaptureService.java 源代码

正在查看: Biko v2.0.23 应用的 ZegoScreenCaptureService.java JAVA 源代码文件

本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。


package im.zego.internal.screencapture;

import android.app.Notification;
import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.app.Service;
import android.content.Intent;
import android.os.Binder;
import android.os.Build;
import android.os.IBinder;

public class ZegoScreenCaptureService extends Service {

    private class ZegoScreenCaptureLocalBinder extends Binder {
        private ZegoScreenCaptureLocalBinder() {
        }

        public ZegoScreenCaptureService getService() {
            return ZegoScreenCaptureService.this;
        }
    }

    @Override
    public IBinder onBind(Intent intent) {
        createNotificationChannel();
        return new ZegoScreenCaptureLocalBinder();
    }

    @Override
    public boolean onUnbind(Intent intent) {
        stopForeground(true);
        return super.onUnbind(intent);
    }

    private void createNotificationChannel() {
        Notification.Builder builder = new Notification.Builder(getApplicationContext());
        if (Build.VERSION.SDK_INT >= 26) {
            builder.setChannelId("notification_id");
        }
        if (Build.VERSION.SDK_INT >= 26) {
            ((NotificationManager) getSystemService("notification")).createNotificationChannel(new NotificationChannel("notification_id", "notification_name", 2));
        }
        Notification build = builder.build();
        build.defaults = 1;
        if (Build.VERSION.SDK_INT >= 29) {
            startForeground(110, build, 32);
        } else {
            startForeground(110, build);
        }
    }
}