connecting your android application to cloud

20
CONNECT SUNSHINE TO CLOUD

Upload: eng-chrispinus-onyancha

Post on 23-Feb-2017

49 views

Category:

Software


2 download

TRANSCRIPT

CONNECT SUNSHINE TO CLOUD

HTTP REQUEST

1. Make HTTP Reuest to the URL2. Read the response from the input stream3. Clean and log any erros

a. Close any input streams

The gist code is here

https://gist.github.com/udacityandroid/d6a7bb21904046a91695

LOGGING

We use the android logcat to view log messages

We can also use the android device monitor

OPEN WEATHER MAP API KEYS

This link will tell you how to use your API key to make requests.

ADD NETWORK CALL

THREADS

Android by default, runs on the main thread also calle the UI thread.

Handles user input and output.

Hence we don’t want o do any task on the main thread that will slow it

ASYNC TASK

Check out the Google Android guide on threading here.

WHY ASYNC TASK IS NOT OPTIMAL

Always seek to eliminate the manual refresh button

A good app should provide the user with data even before he asks

BETTER ALTERNATIVES

MENU BUTTONS

REFRESH BUTTON

Add a menu item with a refresh button with id action_refresh