2012-07-09 100 views
2

我试图用小弹出框在我的应用程序之外设置警报。我通过使用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(); 

     } 
} 

}

如果你们提供的链接,实际的闹钟应用的代码,这将是美妙的。

感谢您的帮助球员。

回答

1

我发现刚刚将该Android中弹出类别清单文件很长一段时间

后的答案。

<activity android:name=".AlarmPopup" android:theme="@android:style/Theme.Dialog" 
      android:clearTaskOnLaunch="true" android:launchMode="singleInstance" 
      android:finishOnTaskLaunch="true" excludeFromRecents="true"/> 

问题得到解决。

我希望这会对某人有所帮助。

0

是的,你应该实际尝试Android的闹钟应用src的here是链接。

对我的另一种答案看看here

+0

谢谢Ankit ..我会看着它回来给你.. – GoCrazy 2012-07-09 14:37:39