Tag: 通知

如何创建一个适用于所有Android设备的时间触发通知

我试图做一个通知,经过一段时间后触发。 为了达到这个目的,我有了这个从BroadCast接收器inheritance的AlarmReceiver类,它可以运行在大约API 23的设备上。它不能在我的模拟器上运行API 27.任何线索我做错了什么? class AlarmReceiver : BroadcastReceiver() { companion object { val PRIMARY_CHANNEL = “dj” } override fun onReceive(context: Context, intent: Intent) { val notificationManager = context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager val notificationIntent = Intent(context, NotificationActivity::class.java) val stackBuilder = TaskStackBuilder.create(context) stackBuilder.addParentStack(NotificationActivity::class.java) stackBuilder.addNextIntent(notificationIntent) val pendingIntent = stackBuilder.getPendingIntent(100, PendingIntent.FLAG_UPDATE_CURRENT) if (android.os.Build.VERSION_CODES.O <= android.os.Build.VERSION.SDK_INT){ //I create the notification channel […]

NotificationListenerService未创建

也许愚蠢的问题,但我已经花了很多时间在这个。 我有我的Kotlin听众: package pl.bmideas.michal.bmnotifier public class MyNotificationListener : NotificationListenerService() { private var apiService :BackendApi? = null; override fun onCreate() { Log.i(“MyNotificationListener” , “Creating NotificationListenerService service”) super.onCreate() (………SOMETHING ELSE…………..) } override fun onDestroy() { super.onDestroy() Log.i(TAG, “DESTROING”) (………SOMETHING ELSE…………..) } override fun onNotificationRemoved(sbn: StatusBarNotification) { val sbnInfo = StatusBarNotificationExtended(sbn) Log.i(TAG, “REMOVED”) } override fun onNotificationPosted(sbn: StatusBarNotification) […]