奥利奥:未运行应用程序时未触发警报

编程入门 行业动态 更新时间:2024-10-19 13:33:56
本文介绍了奥利奥:未运行应用程序时未触发警报的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有一个相对简单的设置,该设置应在一天中的特定时间触发警报并向用户显示通知.这是相对代码,

I have relatively simple setup that should trigger an alarm at certain time of the day and show a notification to user. here is relative code,

设置闹钟

long inTime = /*expirationTime*/ Calendar.getInstance().getTimeInMillis() + 10000; Intent startIntent = new Intent("parking.event"); startIntent.setClass(getBaseContext(), ParkingExpirationWarmingBroadcast.class); PendingIntent startPendingIntent = PendingIntent.getBroadcast(this, 99, startIntent, 0); alarmMgr.setExact(AlarmManager.RTC_WAKEUP, inTime, startPendingIntent);

广播接收器已注册

<receiver android:name=".modules.parking.ParkingExpirationWarmingBroadcast" android:enabled="true"> <intent-filter> <action android:name="parking.event" /> </intent-filter> </receiver>

广播接收器

class ParkingExpirationWarmingBroadcast : BroadcastReceiver() { @SuppressLint("NewApi") override fun onReceive(context: Context, intent: Intent) { } }

仅当应用程序在后台运行时,接收器才会被触发.从多任务中轻扫应用程序后,通知将被清除,并且不会触发新的警报.我在Android 7.0上检查了此设置,无论是否运行应用程序,都会触发BroadcastReceiver.

The receiver is only getting triggered if app is in background. as soon as i swipe the app from multitasking, the notification is cleared and no new Alarms are triggered. I checked this setup on Android 7.0 and BroadcastReceiver is triggered regardless of app running or not.

我知道有关Android Oreo中隐式广播的限制,但是我不认为我上面提到的意图被认为是隐式的.

I am aware regarding restrictions over implicit broadcasts in Android Oreo but i don't believe the intent that i have mentioned above is considered implicit.

谁能指出我做错了什么?

Can anyone point out what i am doing wrong?

推荐答案

强制关闭应用会破坏其组件.这就是强制停止的作用.这不是错误,它是一个很大的功能.遵循以下主题,android框架工程师已对其进行了讨论. groups.google/forum/? fromgroups =#!topic/android-developers/anUoem0qrxU

Force closing an app destroys its components . This is what force stop does. It's not a bug, it is very much a feature. Follow the following thread , it has been discussed by android framework engineers . groups.google/forum/?fromgroups=#!topic/android-developers/anUoem0qrxU

更多推荐

奥利奥:未运行应用程序时未触发警报

本文发布于:2023-11-27 07:32:10,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1637135.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:警报   应用程序   奥利

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!