导航菜单

页面标题

页面副标题

自健身 v3.3.4 - SaveLifeService.java 源代码

正在查看: 自健身 v3.3.4 应用的 SaveLifeService.java JAVA 源代码文件

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


package com.mu.gymtrain.service;

import android.app.Notification;
import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.app.Service;
import android.content.Intent;
import android.os.Build;
import android.os.IBinder;
import com.mu.gymtrain.Activity.ChatActivity;
import com.mu.gymtrain.R;
import com.mu.gymtrain.Utils.FinalTools;
import com.mu.gymtrain.Utils.PreferenceUtils;
import com.mu.gymtrain.Utils.SoundOrVibrateUtils;

public class SaveLifeService extends Service {
    private NotificationManager notificationManager;
    private String notificationId = "channelId";
    private String notificationName = "channelName";

    @Override
    public IBinder onBind(Intent intent) {
        return null;
    }

    @Override
    public void onCreate() {
        super.onCreate();
        PreferenceUtils.getInstance().getString(FinalTools.PHONE, "");
        this.notificationManager = (NotificationManager) getSystemService("notification");
        if (Build.VERSION.SDK_INT >= 26) {
            this.notificationManager.createNotificationChannel(new NotificationChannel(this.notificationId, this.notificationName, 4));
        }
        startForeground(10086, getNotification());
    }

    private Notification getNotification() {
        Notification.Builder smallIcon = new Notification.Builder(this).setContentTitle("自健身").setContentText("客服专属通知位").setSmallIcon(R.mipmap.ic_launcher);
        if (Build.VERSION.SDK_INT >= 26) {
            smallIcon.setChannelId(this.notificationId);
        }
        return smallIcon.build();
    }

    private void callPhone(String confId, String psw) {
        SoundOrVibrateUtils.playRing(getApplicationContext());
        SoundOrVibrateUtils.vibrate(getApplicationContext(), 60000);
        Intent intent = new Intent();
        intent.putExtra("confId", confId);
        intent.putExtra("psw", psw);
        intent.setClass(getApplicationContext(), ChatActivity.class);
        intent.setFlags(276824064);
        startActivity(intent);
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        startService(new Intent(getApplicationContext(), (Class<?>) SaveLifeService.class));
    }
}