我怎样才能解决这个问题的意图? [英] How can I fix this intent issue?

查看:111
本文介绍了我怎样才能解决这个问题的意图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

TL; DR:

如果两个目的都在同一时间运行,我想只有那些意图之一启动。

If two intents are run at the same time, I want only one of those intents to start.

我的游戏在后台运行的服务20秒计时器,当该计时器结束,一个新的活动(游戏结束画面)开始通过一种意图。用户是pressing按钮,在这20个瞬间改变活动(再次,通过意向)。

My game has a 20 second timer running in the background service, and when that timer ends, a new activity (game over screen) starts through an intent. The user is pressing buttons to change activities (again, through intent) in those 20 seconds.

的问题是,如果用户在该计时器结束,下一个活动开始,而不是在游戏结束画面的同时按下按钮。现在,计时器已经结束,用户被卡住随机按按钮没有理由。我该如何解决这个问题? 有没有什么办法,以确保游戏在屏幕上会在20秒后打开?

The problem is, if the user pushes a button at the same time that the timer ends, the next activity starts rather than the game over screen. Now, the timer is over, and the user is stuck randomly pushing buttons for no reason. How can I fix this? Is there any way to make sure that the Game Over screen will open up after 20 seconds?

我还没有提供了大量的code,因为它主要是刚刚起步的意图。如果您需要任何细节,请随时问我。

I haven't provided much code, because it is mainly just starting intents. If you need any detail, feel free to ask me.

推荐答案

我建议你采取一个全局变量作为标志,
让说 INT = 0
现在,初始化为0,并在你的意图都给予条件如下:

I am suggesting you to take a global variable as a flag, let say int = 0 Now initialize it as "0" and on your both intents give condition as below:

 if(i == "0"){
    .
    .
    .
    //fire your intent..
i= 1;
    }

,然后刷新该变量为0时,你want.Hope你有想法。

,And then flush that variable to "0" whenever you want.Hope you got idea.

这篇关于我怎样才能解决这个问题的意图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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