android - 当应用程序终止或在后台时,无法通过 fcm 通知启动活动
问题描述
我需要启动一个设备环活动,我收到了一个 fcm 通知。当应用程序处于前台时,它工作正常。如果应用程序处于后台或终止状态,我正在接收通知,但活动没有开始
operation.setStatus(resources.getString(R.string.operation_value_completed));
resultBuilder.build(operation);
Intent intent = new Intent(context, AlertActivity.class);
intent.putExtra(resources.getString(R.string.intent_extra_type), resources.getString(R.string.intent_extra_ring));
intent.putExtra(resources.getString(R.string.intent_extra_message_text), resources.getString(R.string.intent_extra_stop_ringing));
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP |
Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
context.startActivity(intent);
if (Constants.DEBUG_MODE_ENABLED) {
Log.d(TAG, "Ringing is activated on the device");
}
解决方案
推荐阅读
- node.js - 尝试在之后立即启动 React 时出现错误(项目依赖关系树可能有问题......)
- c - 使用 shm_open 将整数从父进程复制到子进程
- html - 从不同的 HTML 结构解析相同的数据
- django - Docker-compose - 如何将容器数据填充到另一个容器?
- python-3.x - 将 MNIST 图像从 (28, 28, 1) 填充到 (32, 32, 1)
- mysql - 如何使用计数仅返回数字?
- php - 如何使用 DarrylDecode 购物车功能将我的购物车数据存储到 Laravel 中的数据库
- azure-devops - 如何在构建过程中访问 AzureDevops 中的管道变量
- android - Jetpack Navigation - 以编程方式检索嵌套图
- r - 如何在 R 中使用 rselenium 和 rvest 单击锚标记链接?