/* * This is the source code of Telegram for Android v. 1.3.x. * It is licensed under GNU GPL v. 2 or later. * You should have received a copy of the license in this archive (see LICENSE). * * Copyright Nikolai Kudashov, 2013-2018. */ package org.telegram.messenger; import android.app.Notification; import android.app.NotificationChannel; import android.app.NotificationManager; import android.app.PendingIntent; import android.app.Service; import android.content.Context; import android.content.Intent; import android.content.SharedPreferences; import android.os.Build; import android.os.IBinder; import android.provider.Settings; import androidx.core.app.NotificationCompat; public class NotificationsService extends Service { @Override public void onCreate() { super.onCreate(); ApplicationLoader.postInitApplication(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { String CHANNEL_ID = "push_service_channel"; NotificationChannel channel = new NotificationChannel(CHANNEL_ID, LocaleController.getString("PlaceHolder", R.string.PlaceHolder), NotificationManager.IMPORTANCE_DEFAULT); channel.setDescription("NekoX - System"); channel.enableLights(false); channel.enableVibration(false); channel.setSound(null, null); NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); if (notificationManager != null) { notificationManager.createNotificationChannel(channel); } Intent intent = new Intent(Settings.ACTION_CHANNEL_NOTIFICATION_SETTINGS); intent.putExtra(Settings.EXTRA_APP_PACKAGE, getPackageName()); intent.putExtra(Settings.EXTRA_CHANNEL_ID, CHANNEL_ID); PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, 0); Notification notification = new NotificationCompat.Builder(this, CHANNEL_ID) .setSmallIcon(R.drawable.notification) .setColor(0xff11acfa) .setContentTitle(LocaleController.getString("NekogramRunning", R.string.NekogramRunning)) .setContentText(LocaleController.getString("TapToDisable",R.string.TapToDisable)) .setContentIntent(pendingIntent) .setCategory(NotificationCompat.CATEGORY_STATUS) .build(); startForeground(38264, notification); } } @Override public int onStartCommand(Intent intent, int flags, int startId) { return START_STICKY; } @Override public IBinder onBind(Intent intent) { return null; } public void onDestroy() { super.onDestroy(); SharedPreferences preferences = MessagesController.getGlobalNotificationsSettings(); if (preferences.getBoolean("pushService", true)) { Intent intent = new Intent("org.telegram.start"); try { sendBroadcast(intent); } catch (Exception ex) { // 辣鷄miui 就你事最多.jpg } } } }