I am running this file in task.xml
<?xml version=“1.0” encoding=“utf-8" ?>
<!-- Copyright 2016 Roku Corp. All Rights Reserved. -->
<component name=“ContentReader” extends=“Task”>
<script type=“text/brightscript”>
<![CDATA[
sub init()
m.top.functionName = “getAPIResponse”
end sub
sub getAPIResponse()
port = CreateObject(“roMessagePort”)
request = CreateObject(“roUrlTransfer”)
request.setRequest(“GET”)
request.setURL(m.top.contenturi)
jsonString = request.GetToString()
jsonParsed = ParseJson(jsonString)
m.top.content = jsonParsed
end sub
]]>
</script>
</component>
And Used this below function in main.brs file
sub Main()
print “in showChannelSGScreen”
m.readXMLContentTask = createObject(“roSGNode”, “ContentReader”)
m.readXMLContentTask.observeField(“content”, “setcontent”)
m.readXMLContentTask.contenturi = “http://www.sdktestinglab.com/Tutorial/content/xmlcontent.xml”
m.readXMLContentTask.control = “RUN”
readData = m.top.content
print “readData”
end sub
but this function is not executed in main.brs file
Can you please help me to execute this function from main.brs Or provide the sample examples
@NicholasStokes, I can't help you run the task from Main(), but there isn't any need to run a task from Main(). Just put the code from task.xml right in Main(). You can use roUrlTransfer in Main(). Also, please use code tags when posting code. It makes it much, much, much easier to read. To find it, you have to expand the toolbar above the edit box for your post and it looks like </>.
sub Main()
print “in showChannelSGScreen”
port = CreateObject(“roMessagePort”)
request = CreateObject(“roUrlTransfer”)
url = "http://www.sdktestinglab.com/Tutorial/content/xmlcontent.xml"
request.setURL(url)
jsonString = request.GetToString()
jsonParsed = ParseJson(jsonString)
end sub