android - 将应用程序发送到后面并带到前面

标签 android service android-activity background-service

我想开发一个应用程序,它将在特定时间启动并在特定时间关闭。类似于警报但不是警报应用程序。 根据我的想法,我将在应用程序首次启动时启动服务服务将检查当前时间和特定时间以匹配条件以及条件何时关闭应用程序它只会将应用程序发送到后台以便服务运行以及唤醒条件up 发生的服务会把应用程序带到前台。 这可能吗?如果是,请提供示例链接或任何有用的信息。 我也在尝试了解该服务,但对我来说有点复杂,所以如果您有链接可以帮助我了解该服务,那将非常有帮助。谢谢。

已解决的问题:

/*关闭 Activity /

Intent intent = new Intent(Intent.ACTION_MAIN);
intent.addCategory(Intent.CATEGORY_HOME);
intent.addCategory(Intent.CATEGORY_DEFAULT);
startActivity(intent);
MainActivity.this.finish();

或者刚完成 Activity ;

MainActivity.this.finish();

/** 开始 Activity */

Intent i = new Intent();
i.setAction(Intent.ACTION_MAIN);
i.addCategory(Intent.CATEGORY_LAUNCHER);
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
ComponentName cn = new ComponentName(this, MainActivity.class);
i.setComponent(cn);
startActivity(i);

它对我仍然有效,如果有人有更好的解决方案,请在下面发布。

谢谢

最佳答案

您可以创建一个 BroadcastReceiver监听时间变化,并在您指定的时间创建一个 Intent启动或关闭您的主要 Activity .

关于android - 将应用程序发送到后面并带到前面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6928368/

相关文章:

vb.net - 使用以SYSTEM身份运行的vb.net应用程序,如何为每个登录用户启动分离的进程?

java - 确定上下文是否是特定 Activity

android - 如何将参数从 Activity 传递到服务......当用户停止服务时

安卓 : Make 2 services communicate

android - 如何调用一个 Android Intent,该 Intent 需要来自 Codename One Native Code 的结果

java - 为 BlackBerry 编写 Android 应用程序时使用哪个 Android 版本?

android - 应用程序按模块划分?

android - Android fragment 中的动态背景

android - 如何在不同屏幕上保持背景纵横比

c# - 加载空字符串和 Silverlight 4