2

リマインダーアプリを開発し、timer.performWithDelay関数を使用して、実行するタスクを指定した関数を呼び出しました。シミュレーターでは正常に動作します。system.scheduleNotificationを使用する必要があるため、デバイスで実行したい。使い方がわからず、シミュレーターでチェックインできません。私が書いたコードを共有しています。

local function onComplete( event )
print( "index => ".. event.index .. " action => " .. event.action )

local action = event.action
if "clicked" == event.action then

if 2 == event.index then --pressing snooze and setting snooze time to 1mins
audio.stop()
print("**SNOOZED**")
forAlarm1 = timer.performWithDelay (60*1000, compareTime)

elseif 1==event.index then --pressing ok and setting the alarm to repeat mode
print("**ALARM SET TO REPEAT**")
audio.stop()
end
end

終わり

function compareTime()
print("CompareTime is called")
timer.performWithDelay (7*24*3600*1000, compareTime)
audio.play(alarm)
local alert = native.showAlert( "Garbage Collection Reminder", "It's Time", { "OK",     "SNOOZE" },onComplete)

end

forAlarm = timer.performWithDelay (delay*1000, compareTime)

誰かがデバイスで実行するためにコードを変更する方法を教えてもらえますか?

4

1 に答える 1

0

私はそれを考え出した。以下のコードを使用して実行できます。ローカルオプション={alert= "Alert !!!"、badge = 2、sound = "alarm.caf"、}

        -- schedule using seconds from now
        local notification = system.scheduleNotification( delay, options )


        local listener = function( event )
                local notification = system.scheduleNotification( 7*24*3600*1000, options )
            local alert = native.showAlert( "Garbage Collection Reminder", "It's Time", { "OK", "SNOOZE" },onComplete)

        end

        Runtime:addEventListener( "notification", listener )
于 2013-01-31T07:24:14.173 に答える