如何设置报警同样喜欢闹钟应用在Android中? [英] How to Set up Alarm Same like Alarm App in Android?

查看:462
本文介绍了如何设置报警同样喜欢闹钟应用在Android中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想设置报警我的应用程序外,很少弹出框。我做了使用Activity.I的弹出框一直在努力了很长一段时间像闹钟应用程序设置报警,但我得到失败在某些情况下。

I am trying to setup alarm outside of my app with little popup box. I made that popup box by using Activity.I been trying for a long time to setup alarm like Alarm app but i get failed in some situations.

我成功了,如果我使用后退按钮退出从发射活动的应用程式。

I am successful if i am exiting the app from the launch activity by using back button.

但是,当我preSS home键报警保持工作的魅力但在后台上次使用的活动。

But when i press home button the alarm keep working charm but with last used activity in background.

我不知道为什么发生这种情况,我想知道我可以使这项工作与出背景的任何活动时,我pressed home键。

I am not sure why this happening and i would like to know how i can make this work with out any activity in background when i pressed home button.

下面是我的onReceiver code。

Here is my onReceiver Code.

@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();

        }
}

}

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

If you guys provide the link for actual alarm app code that would be fabulous.

感谢您的帮助球员。

推荐答案

我发现很长一段时间后的答案

I found the answer after long time

就在Android的弹出类清单文件中添加的这一点。

Just Added this in Android Popup Class Manifest File.

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

问题得到解决。

我希望这会帮助的人。

这篇关于如何设置报警同样喜欢闹钟应用在Android中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆