(新手)设计决策。链接活动更好还是从服务调用它们更好

发布于 2025-01-05 11:40:19 字数 401 浏览 0 评论 0原文

我正在实现一个游戏,其中许多玩家必须完成多个级别(每个级别的游戏时间非常短)

从逻辑上讲:

for (l = 1; l <= num_levels; l++)
{
    for (p = 1; p <= num_players; p++)
    {
        PLAY (l, p);
    }
}

有 2 个可用选项

  1. 将活动链接到活动
  2. 实现一个服务,其中为每个级别/玩家迭代调用 startActivityForResult () (显然,主应用程序循环将在主线程以外的线程中运行)。

根据已经实施这种“模式”的人的经验,哪种解决方案是最好的,为什么?

非常感谢。

保罗

I am implementing a game in which many players have to complete several levels (very short playing time per level)

Logically speaking :

for (l = 1; l <= num_levels; l++)
{
    for (p = 1; p <= num_players; p++)
    {
        PLAY (l, p);
    }
}

There are 2 options available

  1. Chain Activiity to Activity
  2. Implement a Service in which startActivityForResult () is called for each Level/Player iteration (obviously the main app loop would run in a thread other than the main thread).

Based on experience from those who have already implemented such a "pattern", which solution is best and why ??

Many tnhanks.

Paul

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

趁年轻赶紧闹 2025-01-12 11:40:19

据我了解您想要完成的任务,从服务启动活动并不是一个好主意。我认为很少有这样的情况。

您可以在一项活动中完成这一切。只需让它迭代这两个列表(级别和玩家)并采取相应的行动即可。

From what I understand what you want to accomplish, it would not be a good idea to start Activities from a service. I think it rarely ever is.

You could do this all in one Activity. Just have it iterate over those two Lists (Levels and Players) and act accordingly.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文