add intents docs and samples
This commit is contained in:
44
samples/intent-sample.lua
Normal file
44
samples/intent-sample.lua
Normal file
@@ -0,0 +1,44 @@
|
||||
function on_resume()
|
||||
ui:show_lines{
|
||||
"open browser",
|
||||
"open market",
|
||||
"open google feed",
|
||||
"open player",
|
||||
"send broadcast to launcher (open apps menu)",
|
||||
}
|
||||
end
|
||||
|
||||
function on_click(idx)
|
||||
if idx == 1 then
|
||||
intent:start_activity{
|
||||
action = "android.intent.action.VIEW",
|
||||
data = "https://aiolauncher.app",
|
||||
}
|
||||
elseif idx == 2 then
|
||||
intent:start_activity{
|
||||
action = "android.intent.action.MAIN",
|
||||
category = "android.intent.category.APP_MARKET",
|
||||
}
|
||||
elseif idx == 3 then
|
||||
intent:start_activity{
|
||||
action = "com.google.android.googlequicksearchbox.GOOGLE_SEARCH",
|
||||
extras = {
|
||||
query = "AIO Launcher",
|
||||
},
|
||||
}
|
||||
elseif idx == 4 then
|
||||
intent:start_activity{
|
||||
action = "android.intent.action.VIEW",
|
||||
category = "android.intent.category.DEFAULT",
|
||||
data = "file:///system/product/media/audio/ringtones/Atria.ogg",
|
||||
type = "audio/ogg",
|
||||
}
|
||||
else
|
||||
intent:send_broadcast{
|
||||
action = "ru.execbit.aiolauncher.COMMAND",
|
||||
extras = {
|
||||
cmd = "apps_menu",
|
||||
},
|
||||
}
|
||||
end
|
||||
end
|
||||
11
samples/msg-receiver.lua
Normal file
11
samples/msg-receiver.lua
Normal file
@@ -0,0 +1,11 @@
|
||||
function on_resume()
|
||||
ui:show_text("empty")
|
||||
end
|
||||
|
||||
function on_message(value)
|
||||
if type(value) == "table" then
|
||||
ui:show_text("table first element: "..value[1])
|
||||
else
|
||||
ui:show_text(value)
|
||||
end
|
||||
end
|
||||
17
samples/msg-sender.lua
Normal file
17
samples/msg-sender.lua
Normal file
@@ -0,0 +1,17 @@
|
||||
function on_resume()
|
||||
ui:show_lines{
|
||||
"send text",
|
||||
"send 123",
|
||||
"send table",
|
||||
}
|
||||
end
|
||||
|
||||
function on_click(idx)
|
||||
if idx == 1 then
|
||||
system:send_message("text", "msg-receiver.lua")
|
||||
elseif idx == 2 then
|
||||
system:send_message(1)
|
||||
else
|
||||
system:send_message{ "one", "two", "three" }
|
||||
end
|
||||
end
|
||||
26
samples/shttp-text.lua
Normal file
26
samples/shttp-text.lua
Normal file
@@ -0,0 +1,26 @@
|
||||
-- name = "Chuck Norris jokes (experimental)"
|
||||
-- description = "icndb.com"
|
||||
-- data_source = "icndb.com"
|
||||
-- type = "widget"
|
||||
-- author = "Evgeny Zobnin (zobnin@gmail.com)"
|
||||
-- version = "1.0"
|
||||
|
||||
function on_alarm()
|
||||
local response = shttp:get("http://api.icndb.com/jokes/random")
|
||||
|
||||
if response.error ~= nil then
|
||||
ui:show_text(response.error)
|
||||
return
|
||||
end
|
||||
|
||||
if response.code >= 200 and response.code < 300 then
|
||||
joke = ajson:get_value(response.body, "object object:value string:joke")
|
||||
ui:show_text(joke)
|
||||
end
|
||||
end
|
||||
|
||||
function on_click()
|
||||
if joke ~= nil then
|
||||
system:copy_to_clipboard(joke)
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user