我试图用小弹出框在我的应用程序之外设置警报。我通过使用Activity来创建该弹出框。我一直在尝试设置闹钟应用程序很长时间,但在某些情况下我失败了。如何设置闹钟与Android中的闹钟应用程序相同?
我很成功,如果我通过使用后退按钮退出启动活动的应用程序。
但是当我按回家按钮警报保持工作的魅力,但最后在后台使用的活动。
我不知道为什么会发生这种情况,我想知道如何在后台按下home按钮时使此工作无法进行。
这是我的onReceiver代码。
@Override
public void onReceive(Context context, Intent intent) {
try {
Bundle bundle = intent.getExtras();
String message = bundle.getString("alarm_message");
Intent newIntent = new Intent(context, ReminderPopupMessage.class);
newIntent.putExtra("alarm_message", message);
newIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
newIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
context.startActivity(newIntent);
} catch (Exception e) {
e.printStackTrace();
}
}
}
如果你们提供的链接,实际的闹钟应用的代码,这将是美妙的。
感谢您的帮助球员。
谢谢Ankit ..我会看着它回来给你.. – GoCrazy 2012-07-09 14:37:39