Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我在android中编写了一个自动消息传递应用程序。它在用户指定的日期和时间自动发送消息,包括重复和时间间隔。但我面临的问题是,由于我使用线程睡眠到指定时间,我的应用程序屏幕在线程处于睡眠状态时变为空白。请建议如何处理???
如果应用程序在用户指定的时间和日期发送消息,我建议使用 AlarmManager 和 Service 来完成这项工作,而不是让线程休眠。这样,您的应用程序不必“明显”地运行给用户来执行“cron”工作。