谁能具体讲解下nodeLib.setOnMsgNotify(callback)这个命令。
[url=]import('android.*')
import('java.lang.*')
import('java.util.*')
import('android.widget.*')
import('android.content.Intent')
import('android.content.Context')
import('com.nx.assist.lua.LuaEngine')
local context = LuaEngine.getContext()
function post(callback) --切换到原生UI线程执行指定函数
LuaEngine.runOnUIThread(Runnable{
run = callback
})
Thread.sleep(100)
end
--[===[监听原生吐司或者状态栏信息弹出]===]
local r = nodeLib.setOnMsgNotify(function(what,msg)
if what == 1 then --原生吐司或者状态栏变化
print(what,msg)
end
end)
function 测试吐司()
while true do
post(function()
Toast.makeText(context, "我是原生吐司", Toast.LENGTH_SHORT).show()
end)
sleep(2000)
end
end
if r then
测试吐司()
else
print("监听失败")
end[/url][url=]例子看不懂呀。[/url]
|