- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
我有一个显示通知栏的前台任务,目的是让这个通知栏不可移动。通知的配置是:
Notification notification = new NotificationCompat.Builder(this)
.setContentTitle("Notification")
.setContentText("Notification for app")
.setSmallIcon(R.mipmap.ic_launcher)
.setContent(notificationView)
.setOngoing(true)
.build();
虽然应用了 setongoing(true),但可以在华为设备(Android 5.1.1)上删除通知。尽管它适用于三星 J3。
通知滑动时,华为出现如下画面
我在华为设备上的 strava/endomondo 应用程序上看到的情况是,它们会在用户滑动删除通知后立即恢复通知。
通知如何在用户删除后回到前台?
最佳答案
我终于可以像 strava/endomondo 那样在华为设备上重新启动通知了。
为了触发通知删除事件,我必须使用 setDeleteIntent 并传递接收器类的挂起 Intent 。
Intent intent = new Intent(this, BootCompleteReceiver.class);
PendingIntent pendingIntent = PendingIntent.getBroadcast(this.getApplicationContext(), 0, intent, 0);
Notification notification = new NotificationCompat.Builder(this)
.setContentTitle("Foreground Task")
.setTicker("Notification")
.setContent(notificationView)
.setDeleteIntent(pendingIntent) //the delete intent I used
.setOngoing(true).build();
在receiver的onReceive方法上,我又开始了我的前台服务
@Override
public void onReceive(Context context, Intent intent) {
Intent service = new Intent(context, RTMForegroundService.class);
context.startService(service);
}
现在,每次用户滑动删除通知时,它都会重新开始。
关于android - 用户通过滑动将其删除后,在华为设备上重新启动前台通知(如 Strava/Endomondo),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49001145/
是否有人在华为手机(例如 Honor 8、Honor 7)上遇到位置监听器问题。 我有一个后台服务,可以实现位置监听器,但对于华为手机,它会在大约 5-6 次位置更新后停止工作。 我已将我的应用添加为
我正在使用“ReadSmsManager.StartConsentAsync”,它工作正常。但我有一个问题:官方文档说:“开启读取短信服务,直到获取到符合规则的短信或服务超时(超时时间为5分钟)”。我
阿里、华为、腾讯java技术面试题精选,具体内容如下 jvm的类加载机制是什么?有哪些实现方式? 类加载机制: 类的加载指的是将类的.class文件中的二进制数据读入到内存中,将其放在运行时数
我已按照文档 here和 here (这很简单),但 map View 不加载任何图 block 。 我使用HMS Toolkit,配置向导成功。我还设置了我的 api key ,在我的应用程序类和我
这个问题可能看起来很宽泛,但我会尽力总结一下。 因此,我正在 Play 商店 Multi Timer Free 上复制示例应用程序 应用程序用于设置多个计时器。 我几乎已经完成了该应用程序。但我面临着
好的,logcat 正在显示系统日志,但在我的华为 Ascend 上没有显示应用程序日志。如果我切换到另一台设备,例如我的 Galaxy Nexus 或 Nexus 7,则会显示相同应用(甚至相同 A
根据网友投稿,华为 Watch GT2 1.0.3.16版本更新,新增支持睡眠呼吸暂停研究,优化了GPS 定位速度。 更新日志: 1)新增支持睡眠呼吸暂停研究(配套运动健康 APP 10.0
根据网友投稿,华为 Watch GT2更新了1.0.2.38固件,优化了GPS轨迹及蓝牙耳机兼容性。 【注意事项】 1)运动健康 APP 传输升级包100%后,请继续等待安装进度条完成,确保
这几天我每次发布 APK 都会收到发布前的报告,说它在华为 Mate 9 上失败。报告没有说太多,日志中没有任何崩溃。我能看到的唯一奇怪的是它声称我的应用程序在屏幕截图上有病毒。我附上它显示的内容。由
我正在开发翻译应用程序,我需要说出用户翻译的内容。关注华为Text to Speech医生我得到了错误。 onError: MLTtsError{errorId=11301, errorMsg='Th
我在网上找到的所有现有解决方案都建议执行以下操作: https://www.xda-developers.com/huawei-phones-disable-logcat-heres-how-to-r
我们知道华为和小米在设置选项中有“protected apps option”,这个选项会在屏幕关闭时杀死我们的应用程序,然后无法收到通知和其他...我想警告我的用户关于此选项并打开此设置部分,是否可
据 MSPoweruser援引seekdevice报道,中国国家知识产权局最近批准了华为申请的 AR 智能眼镜专利。此次获得专利的华为 AR 智能眼镜设计包括机身,摄像头组件,伸缩组件,旋转组件和控
我实现了华为 map ,遵循@shirley here解释的所有协议(protocol). map 第一次运行良好。但是在第二次加载时,它会创建一个奇怪的数组越界异常,并在 setContent Vi
我在我的应用程序中有使用 GoogleMaps 的 map ,但现在我需要将我的应用程序上传到 AppGallery,并且我正在尝试使用华为 map 来完成我的功能。 但是华为 map 与谷歌地图不一
当我在我的 Flutter 应用中使用华为 map 时,我把它放在了堆栈小部件中,并放置了许多 float 按钮来访问 map 。 在 map 渲染之前,按钮会显示,但在 map 渲染之后,按钮不会出
我正在尝试了解如何在 linux 中使用 HUAWEI E173 dongle 使用语音功能。 我的加密狗启用了语音功能(语音适用于 Windows 应用程序)。 我可以使用 AT^CVOICE 检查
我有一个安卓应用程序,我正在使用华为 AR 引擎套件。 我有一个扩展名为 .obj 的模型文件。当我在名为 blender 的应用程序中减小其大小后将此文件添加到我的应用程序时,我的模型无法正确显示。
我的应用无法在华为 P8 Lite 上启动,但在其他设备上运行良好。 我搜索了这个问题很长时间,但找不到有效的解决方案。 我的应用程序一直运行没有问题。然后我修复了一些问题,并在华为 P8 Lite
我正在尝试模拟华为 Y530。根据this site , 它具有以下规范: 屏幕:480 x 854 像素,4.5 英寸(~218 ppi 像素密度) 这是我的 WEB APP 在实际设备上的样子:
我是一名优秀的程序员,十分优秀!