我試圖用10秒的間隔創建3個通知。然而,它只播放第一個聲音,它會在10秒內重複播放。你能檢查我的代碼並告訴我我做錯了什麼嗎?Android與Corona的本地通知
local futureTime = 10 --10 seconds
local sounds = {"Icebaby.mp3", "Pokemon.mp3", "Yoshi.mp3"}
i=1
local options = {
alert = "Wake up!",
sound = "Icebaby.mp3" ,
custom = { msg = "Alarm" }
}
local notificationID = system.scheduleNotification(futureTime, options)
local function notificationListener(event)
system.cancelNotification(notificationID)
i=i+1
options.sound=sounds[i]
if(i>3) then
Runtime:removeEventListener ("notification", notificationListener)
else
notificationID = system.scheduleNotification(futureTime, options)
end
end
Runtime:addEventListener("notification", notificationListener)
您是否嘗試打印出i值?所以你可以看看它是否有問題。我可以看到它是一個全球性的,可以從外部進行管理。 –
我做了本地化測試,但現在它只能播放表格中的最後一個聲音。您是否在設備上測試了代碼? –
我現在無法在設備上進行測試,但是您可以使用一些print()函數來跟蹤代碼嗎?你應該使用它們,如果其他塊 –