启动活动使用AlarmManager,没有了BroadcastReceiver

编程入门 行业动态 更新时间:2024-10-24 12:22:47
本文介绍了启动活动使用AlarmManager,没有了BroadcastReceiver的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我希望有人给我一个答案:

我不知道是否有可能(共同)使用AlarmManager直接开始一个活动。该文件没有明确说明这一点。这里只描述Broadcastreceivers的使用。

如果有可能开始我的活动directy,我哪里会收到意向书(onNewIntent)?

非常感谢 让 - 皮埃尔·

解决方案   

我不知道是否有可能(共同)使用AlarmManager直接开始一个活动。

是的。

  

该文件没有明确说明这一点。这里只描述Broadcastreceivers的使用。

使用的BroadcastReceiver 是最常见的场景。这是必需的 _WAKEUP 报警,如果你希望设备可靠地醒来时,警报响起。

从开始 AlarmManager 的活动应该用于闹钟型应用程序,并没有别的。你不知道什么是用户可能会做的手机,当你的活动来到前台,他们可能会很生你的气,如果他们觉得你的入侵是没有道理的。

  

如果有可能开始我的活动directy,我哪里会收到意向书(onNewIntent)?

在默认情况下,该活动的新实例将被创建。如果你使用 FLAG_ACTIVITY_CLEAR_TOP 和 FLAG_ACTIVITY_SINGLE_TOP ,它将提出活动的现有实例,你会得到的意图在 onNewIntent()。

这演示如何使用示例项目 AlarmManager 这种方式。 这演示用户可配置的活动 - 或 - 通知时,警报就会响起。这两者都是在一系列的教程比较深,所以应用程序是一个有点复杂。

I hope that someone has an answer for me:

I wonder if it is possible (and common) to use the AlarmManager for directly starting an Activity. The documentation does not explain this explicitly. It only describes the usage of Broadcastreceivers.

If it is possible to start my Activity directy, where will I receive the Intent (onNewIntent)?

Many thanks Jean-Pierre

解决方案

I wonder if it is possible (and common) to use the AlarmManager for directly starting an Activity.

Yes.

The documentation does not explain this explicitly. It only describes the usage of Broadcastreceivers.

Using a BroadcastReceiver is the most common scenario. It is required for _WAKEUP alarms, if you want the device to reliably wake up when the alarm goes off.

Starting an activity from AlarmManager should be used for "alarm clock"-type applications, and little else. You have no idea what the user might be doing with the phone when your activity comes to the foreground, and they may get very angry with you if they feel that your intrusion is unjustified.

If it is possible to start my Activity directy, where will I receive the Intent (onNewIntent)?

By default, a new instance of the activity will be created. If you use FLAG_ACTIVITY_CLEAR_TOP and FLAG_ACTIVITY_SINGLE_TOP, it will bring forward an existing instance of the activity, and you will get the Intent in onNewIntent().

This sample project demonstrates using AlarmManager this way. This sample project demonstrates user configurable Activity-or-Notification when the alarm goes off. Both of these are relatively deep in a series of tutorials, and so the apps are a bit complex.

更多推荐

启动活动使用AlarmManager,没有了BroadcastReceiver

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

发布评论

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

>www.elefans.com

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