33

Lesson 2. Connect Sunshine to the cloud, Lesson 3. New Activities and Intents

Embed Size (px)

Citation preview

Page 1: Lesson 2. Connect Sunshine to the cloud, Lesson 3. New Activities and Intents

Lesson����������� ������������������  2.����������� ������������������  COnnect����������� ������������������  SUnshine����������� ������������������  to����������� ������������������  the����������� ������������������  cloud

도우미����������� ������������������  이찬형

Page 2: Lesson 2. Connect Sunshine to the cloud, Lesson 3. New Activities and Intents

Introduction

•basic����������� ������������������  UI����������� ������������������  with����������� ������������������  mock����������� ������������������  data����������� ������������������  

•hook����������� ������������������  sunshine����������� ������������������  up����������� ������������������  with����������� ������������������  Cloud����������� ������������������  

•OPenWeatherMap����������� ������������������  API����������� ������������������  

•permission����������� ������������������  System����������� ������������������  

•Network����������� ������������������  I/O

Page 3: Lesson 2. Connect Sunshine to the cloud, Lesson 3. New Activities and Intents

Review����������� ������������������  Data����������� ������������������  Provided����������� ������������������  by����������� ������������������  OpenWeatherMap

•provides����������� ������������������  a����������� ������������������  free����������� ������������������  weather����������� ������������������  data����������� ������������������  

•forecast����������� ������������������  API����������� ������������������  

•Open����������� ������������������  API����������� ������������������  ?

Page 4: Lesson 2. Connect Sunshine to the cloud, Lesson 3. New Activities and Intents

Find����������� ������������������  the����������� ������������������  Query����������� ������������������  We����������� ������������������  want•1����������� ������������������  week����������� ������������������  

•Postal����������� ������������������  code����������� ������������������  

•Json����������� ������������������  

•http://ko.wikipedia.org/wiki/JSON����������� ������������������  

•metric����������� ������������������  (����������� ������������������  matric����������� ������������������  vs����������� ������������������  imperial����������� ������������������  )����������� ������������������  

•http://api.openweathermap.org/data/2.5/forecast/daily?q=94043&mode=json&units=metric&cnt=7

Page 5: Lesson 2. Connect Sunshine to the cloud, Lesson 3. New Activities and Intents

HTTP����������� ������������������  Request����������� ������������������  for����������� ������������������  Weather����������� ������������������  Data

•Make����������� ������������������  Http����������� ������������������  Request����������� ������������������  

•Read����������� ������������������  Response����������� ������������������  from����������� ������������������  input����������� ������������������  stream����������� ������������������  

•Clean����������� ������������������  up����������� ������������������  and����������� ������������������  log����������� ������������������  any����������� ������������������  errors

Page 6: Lesson 2. Connect Sunshine to the cloud, Lesson 3. New Activities and Intents

HTTP����������� ������������������  Requests

•HttpUrlConnection����������� ������������������  vs����������� ������������������  HttpClient����������� ������������������  

•http://aroundck.tistory.com/2301

Page 7: Lesson 2. Connect Sunshine to the cloud, Lesson 3. New Activities and Intents

Logcat

•log.e����������� ������������������  

•adb����������� ������������������  logcat����������� ������������������  

•Android����������� ������������������  Debug����������� ������������������  Monitor

Page 8: Lesson 2. Connect Sunshine to the cloud, Lesson 3. New Activities and Intents

Logging����������� ������������������  on����������� ������������������  Android•ERROR����������� ������������������  

•WARN����������� ������������������  

•INFO����������� ������������������  

•DEBUG����������� ������������������  

•VERBOSE����������� ������������������  

•http://blog.joins.com/media/folderlistslide.asp?uid=xever21&folder=6&list_id=13535949

Page 9: Lesson 2. Connect Sunshine to the cloud, Lesson 3. New Activities and Intents

Network����������� ������������������  Call

•Copy����������� ������������������  and����������� ������������������  paste����������� ������������������  on����������� ������������������  onCreateView����������� ������������������  

•What����������� ������������������  happens����������� ������������������  ?

Page 10: Lesson 2. Connect Sunshine to the cloud, Lesson 3. New Activities and Intents

Main����������� ������������������  Thread����������� ������������������  vs����������� ������������������  Background����������� ������������������  Thread

•Main����������� ������������������  Thread����������� ������������������  ?����������� ������������������  

•Background����������� ������������������  Thread����������� ������������������  ?����������� ������������������  

•Why����������� ������������������  AyncTask����������� ������������������  ?

Page 11: Lesson 2. Connect Sunshine to the cloud, Lesson 3. New Activities and Intents

Which����������� ������������������  Thread����������� ������������������  for����������� ������������������  AcyncTask

•doInBackground()����������� ������������������  

•onPreExcute()����������� ������������������  

•onProgressUpdate()����������� ������������������  

•onPostExcute()

Page 12: Lesson 2. Connect Sunshine to the cloud, Lesson 3. New Activities and Intents

Move����������� ������������������  to����������� ������������������  AsyncTask

•FetchWeatherTask����������� ������������������  

•LOG_TAG����������� ������������������  =����������� ������������������  ?

Page 13: Lesson 2. Connect Sunshine to the cloud, Lesson 3. New Activities and Intents

Why����������� ������������������  AsyncTask����������� ������������������  is����������� ������������������  Not����������� ������������������  Optimal

Page 14: Lesson 2. Connect Sunshine to the cloud, Lesson 3. New Activities and Intents

Menu����������� ������������������  Buttons

Page 15: Lesson 2. Connect Sunshine to the cloud, Lesson 3. New Activities and Intents

Refresh����������� ������������������  Button����������� ������������������  Behavior

•inflate����������� ������������������  in����������� ������������������  Forecast����������� ������������������  Fragment����������� ������������������  

•setHasOptionMenu(true)����������� ������������������  

•onOptionItemSelected()

Page 16: Lesson 2. Connect Sunshine to the cloud, Lesson 3. New Activities and Intents

Permissions

•app����������� ������������������  run����������� ������������������  within����������� ������������������  its����������� ������������������  instance����������� ������������������  in����������� ������������������  AVM����������� ������������������  

•manifest����������� ������������������  

•absolute����������� ������������������  minimum����������� ������������������  of����������� ������������������  persons����������� ������������������  

•<uses-permission����������� ������������������  android����������� ������������������  :����������� ������������������  name����������� ������������������  =����������� ������������������  “android.permission.INTERNET”/>

Page 17: Lesson 2. Connect Sunshine to the cloud, Lesson 3. New Activities and Intents

Postal����������� ������������������  Code����������� ������������������  Param����������� ������������������  and����������� ������������������  Parsing����������� ������������������  JSONObject

•UriBuilder����������� ������������������  

•JSONObject����������� ������������������  

•http://ralroo.tistory.com/6

Page 18: Lesson 2. Connect Sunshine to the cloud, Lesson 3. New Activities and Intents

Update����������� ������������������  the����������� ������������������  Adapter

•ArrayAdapter<String>����������� ������������������  mForecastAdapter����������� ������������������  

•onPostExcute

Page 19: Lesson 2. Connect Sunshine to the cloud, Lesson 3. New Activities and Intents
Page 20: Lesson 2. Connect Sunshine to the cloud, Lesson 3. New Activities and Intents

Lesson����������� ������������������  3.����������� ������������������  New����������� ������������������  Activities����������� ������������������  and����������� ������������������  Intents

도우미����������� ������������������  이찬형

Page 21: Lesson 2. Connect Sunshine to the cloud, Lesson 3. New Activities and Intents

Introduction����������� ������������������  to����������� ������������������  Lession3

•how����������� ������������������  to����������� ������������������  create����������� ������������������  activities����������� ������������������  

•how����������� ������������������  to����������� ������������������  navigate����������� ������������������  between����������� ������������������  screens

Page 22: Lesson 2. Connect Sunshine to the cloud, Lesson 3. New Activities and Intents

Sunshine����������� ������������������  App����������� ������������������  UX����������� ������������������  Mocks

Page 23: Lesson 2. Connect Sunshine to the cloud, Lesson 3. New Activities and Intents

List����������� ������������������  Item����������� ������������������  Click����������� ������������������  Listener

•setOnItemClickListener����������� ������������������  

•Toast����������� ������������������  

•useful����������� ������������������  for����������� ������������������  debugging

Page 24: Lesson 2. Connect Sunshine to the cloud, Lesson 3. New Activities and Intents

Create����������� ������������������  New����������� ������������������  Activity

•Blank����������� ������������������  Activity����������� ������������������  with����������� ������������������  Fragment����������� ������������������  

•http://blog.pluralsight.com/android-fragments����������� ������������������  

•Hierachical����������� ������������������  Parent����������� ������������������  :����������� ������������������  MainActivity

Page 25: Lesson 2. Connect Sunshine to the cloud, Lesson 3. New Activities and Intents

Intents����������� ������������������  Framework����������� ������������������  

•explicitly����������� ������������������  intent����������� ������������������  

•startActivity����������� ������������������  -����������� ������������������  lunch����������� ������������������  Detail����������� ������������������  Activity����������� ������������������  

•packaged����������� ������������������  as����������� ������������������  Extras����������� ������������������  -����������� ������������������  Display����������� ������������������  Content����������� ������������������  in����������� ������������������  Detail����������� ������������������  Activity����������� ������������������  

•Implicit����������� ������������������  intent

Page 26: Lesson 2. Connect Sunshine to the cloud, Lesson 3. New Activities and Intents

Setting����������� ������������������  UX

•DON’T����������� ������������������  make����������� ������������������  everything����������� ������������������  a����������� ������������������  setting

Page 27: Lesson 2. Connect Sunshine to the cloud, Lesson 3. New Activities and Intents

Preference

•CheckBox,����������� ������������������  List,����������� ������������������  EditText����������� ������������������  

•SharedPreference����������� ������������������  

•PreferenceActivity����������� ������������������  

•PreferenceFragment

Page 28: Lesson 2. Connect Sunshine to the cloud, Lesson 3. New Activities and Intents

Location����������� ������������������  Setting����������� ������������������  XML

•pref_general.xml����������� ������������������  

•EditTextPreference����������� ������������������  

•addPreferencesFromResource����������� ������������������  

•bindPreferenceSummaryToValue

Page 29: Lesson 2. Connect Sunshine to the cloud, Lesson 3. New Activities and Intents

Use����������� ������������������  SharedPreference

•Update����������� ������������������  Data����������� ������������������  on����������� ������������������  Activity����������� ������������������  Start����������� ������������������  

•Temperature����������� ������������������  Units����������� ������������������  Setting

Page 30: Lesson 2. Connect Sunshine to the cloud, Lesson 3. New Activities and Intents

Add����������� ������������������  Map����������� ������������������  Location����������� ������������������  Intent•Implicit����������� ������������������  Intents����������� ������������������  

•“geo:0,0?”����������� ������������������  

•Intent.ACTION_VIEW����������� ������������������  

•resolveActivity����������� ������������������  

•Maps����������� ������������������  app����������� ������������������  included����������� ������������������  an����������� ������������������  intent����������� ������������������  filter

Page 31: Lesson 2. Connect Sunshine to the cloud, Lesson 3. New Activities and Intents

Share����������� ������������������  Intent����������� ������������������  is����������� ������������������  Awesome•Android����������� ������������������  4.0����������� ������������������  

•Share����������� ������������������  action����������� ������������������  provider����������� ������������������  

•support����������� ������������������  library����������� ������������������  

•Flags����������� ������������������  :����������� ������������������  Intent.FALG_ACTIVITY_CLEAR_WHEN_TASk_RSET����������� ������������������  

•http://theeye.pe.kr/archives/1298����������� ������������������  

•Intent.ACTION_SEND

Page 32: Lesson 2. Connect Sunshine to the cloud, Lesson 3. New Activities and Intents

Broadcast����������� ������������������  Intent

•device����������� ������������������  is����������� ������������������  charing����������� ������������������  

•finished����������� ������������������  rebooting����������� ������������������  

•sendBroadcast����������� ������������������  

•receiver����������� ������������������  

•intent����������� ������������������  filters

Page 33: Lesson 2. Connect Sunshine to the cloud, Lesson 3. New Activities and Intents

Manifest����������� ������������������  vs����������� ������������������  Dynamic