【问题标题】:My app is not working after it wakeup from sleep or suspend state我的应用从睡眠或挂起状态唤醒后无法运行
【发布时间】:2012-02-14 19:11:33
【问题描述】:

当设备进入睡眠状态时,我的电晕应用程序无法运行。没有按钮没有响应继续我的游戏。 我使用以下代码来跟踪系统事件 .当屏幕关闭时它会打印 applicationSuspend 但在屏幕上它永远不会打印“applicationResume”[使用 android adb eclipse 来显示打印消息]

 local function onSystemEvent( event )

 if( event.type == "applicationExit" ) then
  print("applicationExit")
    db:close()
  elseif event.type == "applicationSuspend" then

   print("applicationSuspend")
    elseif event.type == "applicationResume" then
      print("applicationResume")
   elseif event.type == "applicationStart" then
  print("applicationStart")
end
end

有什么办法吗?

【问题讨论】:

  • 请包含“周围”的代码,如果。比如它在什么函数里。
  • @kikito 我将它包含在 main.lua 中...不需要特殊功能..\
  • 尝试完全使用 Shane 的代码。我怀疑您的问题可能是您的某个 if 中的某种错字。
  • @kikito 我使用了 Shane Gadsby 的代码,但 applicationResume 从未调用过,但所有其他 3 个都根据事件工作
  • 那我不知道你还能做什么。您是否尝试在 Corona SDK 论坛上发布您的问题?

标签: android lua coronasdk


【解决方案1】:

正如我确定 Kikito 所指出的那样;在我们提供更多帮助之前,我们可能需要拥有它内部的功能。

据我所知,这种事件类型只能在a内部使用:

local function onSystemEvent( event )

   print( "System event name and type: " .. event.name, event.type )
end

Runtime:addEventListener( "system", onSystemEvent )

样式化函数。

这就是你使用它的方式吗?

【讨论】:

    猜你喜欢
    • 2016-03-05
    • 1970-01-01
    • 2012-05-29
    • 2020-11-19
    • 2011-10-06
    • 2021-01-20
    • 1970-01-01
    • 1970-01-01
    • 2012-10-08
    相关资源
    最近更新 更多