Skip to content

Instantly share code, notes, and snippets.

@willrax
Created December 21, 2014 22:01
Show Gist options
  • Save willrax/cec906a7a4ec56983fda to your computer and use it in GitHub Desktop.
Save willrax/cec906a7a4ec56983fda to your computer and use it in GitHub Desktop.
class Client < Android::OS::AsyncTask
def doInBackground(params)
url = Java::Net::URL.new("http://www.bom.gov.au/fwo/IDN60901/IDN60901.94768.json")
reader = Java::IO::BufferedReader.new(Java::IO::InputStreamReader.new(url.openStream))
builder = Java::Lang::StringBuilder.new("")
while ((line = reader.readLine()) != nil) do
builder.append(line)
end
puts builder.toString
reader.close
end
end
class MainActivity < Android::App::Activity
def onCreate(savedInstanceState)
super
@content_layout = Android::Widget::FrameLayout.new(self)
@content_layout.setId(Android::View::View.generateViewId)
@content_layout.backgroundColor = Android::Graphics::Color.parseColor("#FF0099CC")
client = Client.new
client.execute({})
self.setContentView(@content_layout)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment