Pro Yearly is on sale from $80 to $50! »

Android 1.5 - 8.0 Walk through - Retro/Prospective Android Application Development

Android 1.5 - 8.0 Walk through - Retro/Prospective Android Application Development

Bbe9718bebdafbdc8dabbe3cadf1bc46?s=128

Keishin Yokomaku

October 09, 2017
Tweet

Transcript

  1. Android 1.5~8.0 Walkthrough - Retro/Prospective Android Application Development - Keishin

    Yokomaku (@KeithYokoma) - DevFest Tokyo 2017
  2. Retro/Prospective Android Application About Me ▸ ԣນܓਅ - Keishin Yokomaku

    ▸ Drivemode, Inc. / Principal Engineer ▸ KeithYokoma: GitHub / Twitter / Qiita / Tumblr / Stack Overflow ▸ Books: TechBooster / Development guide for mobile app ▸ Fun: Gymnastics / Cycling / Photography / Motorsport 2
  3. 3 Retro/Prospective Android Application Development

  4. Retro/Prospective Android Application Do you know of… 4

  5. Back in time to Android 1.5 5

  6. Retro/Prospective Android Application Activity Lifecycle 6 1.0 1.1 Cupcake Donut

    Eclair Froyo Gingerbread Honeycomb Ice Cream Sandwich Jelly Bean Kitkat Lollipop Marshmallow Nougat Oreo
  7. Retro/Prospective Android Application Activity Lifecycle 7 ผͷը໘͔Β໭͖ͬͯͨͱ͖ ը໘Λ࠷ॳʹ্ཱͪ͛ͨ࣌ ը໘Λดͨ͡ͱ͖ ը໘Λճసͨ͠ͱ͖…

    ϗʔϜϘλϯΛ͓ͨ͠ͱ͖ ผͷը໘΁ભҠͨ͠ͱ͖… ผͷΞϓϦ͔Β໭͖ͬͯͯ
 ࣗ෼ͷϓϩηε͕ࢮΜͰ͍ͨͱ͖ μΠΞϩάΛදࣔͨ͠ͱ͖ ը໘ͷҰ෦͕ޙΖʹݟ͍͑ͯΔͱ͖ 1.0 1.1 Cupcake Donut Eclair Froyo Gingerbread Honeycomb Ice Cream Sandwich Jelly Bean Kitkat Lollipop Marshmallow Nougat Oreo
  8. Retro/Prospective Android Application Activity Lifecycle ▸ Activity ͸ઈ͑ͣঢ়ଶ͕ભҠ͢Δ ▸ ը໘ભҠʹΑΔঢ়ଶͷભҠ

    ▸ ୺຤ͷঢ়ଶมԽʢճస΍ઃఆมߋͳͲʣʹΑΔঢ়ଶͷભҠ ▸ ଞͷΞϓϦͷঢ়ଶมԽʢϝϞϦͷ࢖༻ঢ়گͳͲʣʹΑΔঢ়ଶͷભҠ ▸ etc… 8 1.0 1.1 Cupcake Donut Eclair Froyo Gingerbread Honeycomb Ice Cream Sandwich Jelly Bean Kitkat Lollipop Marshmallow Nougat Oreo
  9. Retro/Prospective Android Application Activity Lifecycle ▸ গͳ͍ϝϞϦۭؒΛޮ཰తʹ࢖͏ͨΊͷ࢓૊Έ ▸ Ϣʔβʹݟ͍͑ͯΔ΋ͷ͕࠷΋ॏཁ ▸

    Ϣʔβ͕௚ۙͰ࢖ͬͨ΋ͷ͸͙͢࠶։Ͱ͖ΔΑ͏ʹͳ͍ͬͯΔ ▸ ࢖Θͳ͘ͳΓͦ͏ͳ΋ͷ͔ΒͲΜͲΜϝϞϦ͔Β௥͍ग़͢ ▸ ϝϞϦ͕ͨ͘͞ΜඞཁͳΞϓϦΛ࢖͏ͱ͖͸௚ۙͰ࢖ͬͨ΋ͷ΋௥͍ग़͢ 9 1.0 1.1 Cupcake Donut Eclair Froyo Gingerbread Honeycomb Ice Cream Sandwich Jelly Bean Kitkat Lollipop Marshmallow Nougat Oreo
  10. Retro/Prospective Android Application Activity Lifecycle ▸ ୺຤ͷઃఆ΍ঢ়ଶ(Configuration)ͷมԽʹ௥ै͠΍͘͢͢Δ࢓૊Έ ▸ ը໘͕ճసͨ͠ΒϨΠΞ΢τΛ࡞Γ௚͢ ▸

    ݴޠઃఆΛม͑ͨΒݴޠϦιʔεΛಡΈ௚͢ ▸ ໷ʹͳͬͨΒը૾ϦιʔεΛಡΈ௚͢ 10 1.0 1.1 Cupcake Donut Eclair Froyo Gingerbread Honeycomb Ice Cream Sandwich Jelly Bean Kitkat Lollipop Marshmallow Nougat Oreo
  11. Retro/Prospective Android Application Activity Lifecycle ▸ ΞϓϦʹݻ༗ͳঢ়ଶΛ؅ཧ͢ΔͨΊͷϝιου ▸ Activity#onCreate(Bundle) ▸

    Activity#onRestoreInstanceState(Bundle) ▸ Activity#onSaveInstanceState(Bundle) ▸ Activity#onRetainNonConfigurationInstance() ▸ Activity#getLastNonConfigurationInstance() 11 1.0 1.1 Cupcake Donut Eclair Froyo Gingerbread Honeycomb Ice Cream Sandwich Jelly Bean Kitkat Lollipop Marshmallow Nougat Oreo
  12. Retro/Prospective Android Application Activity Lifecycle and Asynchronous Task Lifecycle ▸

    Http௨৴ͳͲ࣌ؒͷ͔͔Δॲཧ͸ผεϨουͰ࣮ߦ͢Δ(ඇಉظॲཧ) ▸ UI εϨουͰ࣮ߦ͢Δͱͦͷॲཧ͕ऴΘΔ·Ͱ UI ͕ૢ࡞ෆೳʹͳΔ 12 Activity Asynchronous Task 1.0 1.1 Cupcake Donut Eclair Froyo Gingerbread Honeycomb Ice Cream Sandwich Jelly Bean Kitkat Lollipop Marshmallow Nougat Oreo
  13. Retro/Prospective Android Application Activity Lifecycle and Asynchronous Task Lifecycle ▸

    UI εϨουͰಈ͘ Activity ͱผεϨουͰಈ͘ඇಉظॲཧ͸ผͷϥΠϑαΠΫϧ ▸ Activity ͕ੜ͖͍ͯΔؒʹඇಉظॲཧ͕ऴΘΔͱ͸ݶΒͳ͍ 13 Activity Asynchronous Task Destroyed! Finish! 1.0 1.1 Cupcake Donut Eclair Froyo Gingerbread Honeycomb Ice Cream Sandwich Jelly Bean Kitkat Lollipop Marshmallow Nougat Oreo
  14. Retro/Prospective Android Application ඇಉظॲཧ - Before AsyncTask ▸ εϨουͰͷॲཧͱ UI

    ΁ͷίʔϧόοΫ͸શͯࣗ෼Ͱॻ͘ ▸ εϨουϓʔϧͳͲ΋ࣗલͰ४උ ▸ ίʔϧόοΫͷͨΊʹ Handler Λ͔ͭ͏ 14 1.0 1.1 Cupcake Donut Eclair Froyo Gingerbread Honeycomb Ice Cream Sandwich Jelly Bean Kitkat Lollipop Marshmallow Nougat Oreo
  15. Retro/Prospective Android Application ඇಉظॲཧ - AsyncTask ▸ ඇಉظॲཧͷϥΠϑαΠΫϧΛද͢ந৅Ϋϥε ▸ AsyncTask#onPreExecute():

    ඇಉظॲཧͷ࣮ߦલͷίʔϧόοΫ ▸ AsyncTask#doInBackground(): ඇಉظॲཧͷத਎ ▸ AsyncTask#onPostExecute(): ඇಉظॲཧͷ࣮ߦޙͷίʔϧόοΫ ▸ εϨουͷ؅ཧ͸ AsyncTask ͕΍ͬͯ͘ΕΔ 15 1.0 1.1 Cupcake Donut Eclair Froyo Gingerbread Honeycomb Ice Cream Sandwich Jelly Bean Kitkat Lollipop Marshmallow Nougat Oreo
  16. Retro/Prospective Android Application ඇಉظॲཧ - AsyncTask public class MainActivity extends

    Activity { static class MyAsyncTask extends AsyncTask<Void, Void, Void> { private WeakReference<MyActivity> mRef; public MyAsyncTask(MyActivity activity) { mRef = new WeakReference<>(activity); } @Override public Void doInBackground(Void… args) { // do something heavy return null; } @Override public void onPostExecute(Void result) { // callback to activity } } } 16 1.0 1.1 Cupcake Donut Eclair Froyo Gingerbread Honeycomb Ice Cream Sandwich Jelly Bean Kitkat Lollipop Marshmallow Nougat Oreo
  17. Retro/Prospective Android Application ඇಉظॲཧ - AsyncTask public class MainActivity extends

    Activity { static class MyAsyncTask extends AsyncTask<Void, Void, Void> { private WeakReference<MyActivity> mRef; public MyAsyncTask(MyActivity activity) { mRef = new WeakReference<>(activity); } @Override public Void doInBackground(Void… args) { // do something heavy return null; } @Override public void onPostExecute(Void result) { // callback to activity } } } 17 1.0 1.1 Cupcake Donut Eclair Froyo Gingerbread Honeycomb Ice Cream Sandwich Jelly Bean Kitkat Lollipop Marshmallow Nougat Oreo
  18. Retro/Prospective Android Application ඇಉظॲཧ - AsyncTask public class MainActivity extends

    Activity { static class MyAsyncTask extends AsyncTask<Void, Void, Void> { private WeakReference<MyActivity> mRef; public MyAsyncTask(MyActivity activity) { mRef = new WeakReference<>(activity); } @Override public Void doInBackground(Void… args) { // do something heavy return null; } @Override public void onPostExecute(Void result) { // callback to activity } } } 18 1.0 1.1 Cupcake Donut Eclair Froyo Gingerbread Honeycomb Ice Cream Sandwich Jelly Bean Kitkat Lollipop Marshmallow Nougat Oreo
  19. Retro/Prospective Android Application ඇಉظॲཧ - AsyncTask public class MainActivity extends

    Activity { static class MyAsyncTask extends AsyncTask<Void, Void, Void> { private WeakReference<MyActivity> mRef; public MyAsyncTask(MyActivity activity) { mRef = new WeakReference<>(activity); } @Override public Void doInBackground(Void… args) { // do something heavy return null; } @Override public void onPostExecute(Void result) { // callback to activity } } } 19 1.0 1.1 Cupcake Donut Eclair Froyo Gingerbread Honeycomb Ice Cream Sandwich Jelly Bean Kitkat Lollipop Marshmallow Nougat Oreo
  20. Retro/Prospective Android Application ඇಉظॲཧ - AsyncTask public class MainActivity extends

    Activity { static class MyAsyncTask extends AsyncTask<Void, Void, Void> { private WeakReference<MyActivity> mRef; public MyAsyncTask(MyActivity activity) { mRef = new WeakReference<>(activity); } @Override public Void doInBackground(Void… args) { // do something heavy return null; } @Override public void onPostExecute(Void result) { // callback to activity } } } 20 1.0 1.1 Cupcake Donut Eclair Froyo Gingerbread Honeycomb Ice Cream Sandwich Jelly Bean Kitkat Lollipop Marshmallow Nougat Oreo
  21. Retro/Prospective Android Application ඇಉظॲཧ - AsyncTask public class MainActivity extends

    Activity { private MyAsyncTask mTask; public void onButtonClick(View view) { if (mTask != null) return; mTask = new MyAsyncTask(this); mTask.execute(); } public void onFinishAsyncTask() { mTask = null; } } 21 1.0 1.1 Cupcake Donut Eclair Froyo Gingerbread Honeycomb Ice Cream Sandwich Jelly Bean Kitkat Lollipop Marshmallow Nougat Oreo
  22. Retro/Prospective Android Application ඇಉظॲཧ - AsyncTask public class MainActivity extends

    Activity { private MyAsyncTask mTask; public void onButtonClick(View view) { if (mTask != null) return; mTask = new MyAsyncTask(this); mTask.execute(); } public void onFinishAsyncTask() { mTask = null; } } 22 1.0 1.1 Cupcake Donut Eclair Froyo Gingerbread Honeycomb Ice Cream Sandwich Jelly Bean Kitkat Lollipop Marshmallow Nougat Oreo
  23. Retro/Prospective Android Application ඇಉظॲཧ - AsyncTask public class MainActivity extends

    Activity { private MyAsyncTask mTask; public void onButtonClick(View view) { if (mTask != null) return; mTask = new MyAsyncTask(this); mTask.execute(); } public void onFinishAsyncTask() { mTask = null; } } 23 1.0 1.1 Cupcake Donut Eclair Froyo Gingerbread Honeycomb Ice Cream Sandwich Jelly Bean Kitkat Lollipop Marshmallow Nougat Oreo
  24. Retro/Prospective Android Application AsyncTask Issues ▸ Activity ͷ࣮૷ͱີ݁߹ʹͳΓ΍͔ͬͨ͢ ▸ interface

    Ͱղܾ ▸ ίʔϧόοΫΛऑࢀরͰอ࣋͠ͳ͍ͱϝϞϦϦʔΫ ▸ Activity ͱඇಉظॲཧͷϥΠϑαΠΫϧͷࠩҟ͸ຒΊΒΕ͍ͯͳ͍ ▸ ௕͔͔࣌ؒΔܭࢉॲཧʹ͸޲͔ͳ͍ 24 1.0 1.1 Cupcake Donut Eclair Froyo Gingerbread Honeycomb Ice Cream Sandwich Jelly Bean Kitkat Lollipop Marshmallow Nougat Oreo
  25. Retro/Prospective Android Application ΋͏ͻͱͭͷඇಉظॲཧ - IntentService ▸ UI ͱ͸ؔ࿈ͷͳ͍ɺόοΫάϥ΢ϯυॲཧͷͨΊͷΫϥε ▸

    ؆୯ͳδϣϒΩϡʔͱͯ͠࢖͑Δ ▸ ͨͩ͠ϝϞϦ্ʹ͔͠δϣϒ͕ͳ͍ͷͰشൃ͢Δ 25 1.0 1.1 Cupcake Donut Eclair Froyo Gingerbread Honeycomb Ice Cream Sandwich Jelly Bean Kitkat Lollipop Marshmallow Nougat Oreo Activity Destroyed! IntentService Intent Destroyed!
  26. Retro/Prospective Android Application ඇಉظॲཧ - IntentService public class MainIntentService extends

    IntentServie { public MainIntentService() { super(“MainIntentService”); } public MainIntentService(String name) { super(name); } @Override protected void onHandleIntent(Intent intent) { // ඇಉظॲཧͷத਎ } } 26 1.0 1.1 Cupcake Donut Eclair Froyo Gingerbread Honeycomb Ice Cream Sandwich Jelly Bean Kitkat Lollipop Marshmallow Nougat Oreo
  27. Retro/Prospective Android Application ඇಉظॲཧ - IntentService public class MainIntentService extends

    IntentServie { public MainIntentService() { super(“MainIntentService”); } public MainIntentService(String name) { super(name); } @Override protected void onHandleIntent(Intent intent) { // ඇಉظॲཧͷத਎ } } 27 1.0 1.1 Cupcake Donut Eclair Froyo Gingerbread Honeycomb Ice Cream Sandwich Jelly Bean Kitkat Lollipop Marshmallow Nougat Oreo
  28. Retro/Prospective Android Application Network I/O ▸ Apache HttpClient ▸ Apache

    ͕ग़͍ͯ͠Δ൚༻ͷ Http ௨৴ϥΠϒϥϦ ▸ ΍Γ͍ͨ͜ͱ͸େମͰ͖Δ ▸ ڊେ ▸ Android ͷ API ʹ૊Έࠐ·Ε͍ͯΔ 28 1.0 1.1 Cupcake Donut Eclair Froyo Gingerbread Honeycomb Ice Cream Sandwich Jelly Bean Kitkat Lollipop Marshmallow Nougat Oreo
  29. Retro/Prospective Android Application Network I/O ▸ Http(s)URLConnection ▸ Java ͷ

    API ʹ૊Έࠐ·Ε͍ͯΔ Http ௨৴ϥΠϒϥϦ ▸ γϯϓϧͰ͍ܰ ▸ Android ͷ API ʹ૊Έࠐ·Ε͍ͯΔ ▸ Froyo(Andorid 2.2)·Ͱόά͍ͬͯͨ 29 1.0 1.1 Cupcake Donut Eclair Froyo Gingerbread Honeycomb Ice Cream Sandwich Jelly Bean Kitkat Lollipop Marshmallow Nougat Oreo
  30. Retro/Prospective Android Application Disk I/O ▸ ϑΝΠϧʹॻ͖ग़֤͢छ API ▸ File

    API (java.io) ▸ SQLite ▸ SharedPreferences 30 1.0 1.1 Cupcake Donut Eclair Froyo Gingerbread Honeycomb Ice Cream Sandwich Jelly Bean Kitkat Lollipop Marshmallow Nougat Oreo
  31. Retro/Prospective Android Application Disk I/O ▸ SharedPreferences ʹॻ͖ࠐΉϝιου ▸ commit():

    ॳظ͔Β͋ΔɻϑΝΠϧʹಉظॻ͖ࠐΈɻ ▸ apply(): Gingerbread ͔ΒɻϝϞϦʹॻ͍ͨ΋ͷΛޙͰඇಉظॻ͖ࠐΈɻ 31 1.0 1.1 Cupcake Donut Eclair Froyo Gingerbread Honeycomb Ice Cream Sandwich Jelly Bean Kitkat Lollipop Marshmallow Nougat Oreo
  32. Retro/Prospective Android Application ύϑΥʔϚϯεͷϞχλϦϯά - StrictMode ▸ ϝΠϯεϨουΛϒϩοΫ͢Δॲཧͷݕ஌ ▸ ωοτϫʔΫ௨৴

    ▸ σΟεΫ I/O ▸ Ϧιʔεͷด͡๨Ε΋ݕ஌Ͱ͖Δ ▸ Closeable, Cursor ͳͲ 32 1.0 1.1 Cupcake Donut Eclair Froyo Gingerbread Honeycomb Ice Cream Sandwich Jelly Bean Kitkat Lollipop Marshmallow Nougat Oreo
  33. Retro/Prospective Android Application ύϑΥʔϚϯεͷϞχλϦϯά - StrictMode public class MyApplication extends

    Application { @Override public void onCreate() { if (BuildConfig.DEBUG) { StrictMode.enableDefaults(); } } } 33 1.0 1.1 Cupcake Donut Eclair Froyo Gingerbread Honeycomb Ice Cream Sandwich Jelly Bean Kitkat Lollipop Marshmallow Nougat Oreo
  34. Retro/Prospective Android Application ύϑΥʔϚϯεͷϞχλϦϯά - StrictMode public class MyApplication extends

    Application { @Override public void onCreate() { if (BuildConfig.DEBUG) { StrictMode.enableDefaults(); } } } 34 1.0 1.1 Cupcake Donut Eclair Froyo Gingerbread Honeycomb Ice Cream Sandwich Jelly Bean Kitkat Lollipop Marshmallow Nougat Oreo
  35. Retro/Prospective Android Application ύϑΥʔϚϯεͷϞχλϦϯά - StrictMode public class MyApplication extends

    Application { @Override public void onCreate() { if (BuildConfig.DEBUG) { StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder() .detectDiskReads() .detectDiskWrites() .detectNetwork() .penaltyLog() .build()); StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder() .detectLeakedSqlLiteObjects() .detectLeakedClosableObjects() .penaltyDeath() .build()); } } } 35 1.0 1.1 Cupcake Donut Eclair Froyo Gingerbread Honeycomb Ice Cream Sandwich Jelly Bean Kitkat Lollipop Marshmallow Nougat Oreo
  36. Retro/Prospective Android Application ύϑΥʔϚϯεͷϞχλϦϯά - StrictMode public class MyApplication extends

    Application { @Override public void onCreate() { if (BuildConfig.DEBUG) { StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder() .detectDiskReads() .detectDiskWrites() .detectNetwork() .penaltyLog() .build()); StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder() .detectLeakedSqlLiteObjects() .detectLeakedClosableObjects() .penaltyDeath() .build()); } } } 36 1.0 1.1 Cupcake Donut Eclair Froyo Gingerbread Honeycomb Ice Cream Sandwich Jelly Bean Kitkat Lollipop Marshmallow Nougat Oreo
  37. Retro/Prospective Android Application ύϑΥʔϚϯεͷϞχλϦϯά - StrictMode public class MyApplication extends

    Application { @Override public void onCreate() { if (BuildConfig.DEBUG) { StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder() .detectDiskReads() .detectDiskWrites() .detectNetwork() .penaltyLog() .build()); StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder() .detectLeakedSqlLiteObjects() .detectLeakedClosableObjects() .penaltyDeath() .build()); } } } 37 1.0 1.1 Cupcake Donut Eclair Froyo Gingerbread Honeycomb Ice Cream Sandwich Jelly Bean Kitkat Lollipop Marshmallow Nougat Oreo
  38. Retro/Prospective Android Application AsyncTask Issues ▸ Activity ͕࠶ੜ੒͞Εͨͱ͖ 38 Activity

    AsyncTask Destroyed! Finish! ? Activity 1.0 1.1 Cupcake Donut Eclair Froyo Gingerbread Honeycomb Ice Cream Sandwich Jelly Bean Kitkat Lollipop Marshmallow Nougat Oreo
  39. Retro/Prospective Android Application AsyncTask Issues ▸ Activity ͕࠶ੜ੒͞Εͨͱ͖ ▸ AsyncTask

    ͷΠϯελϯεΛ࠶ੜ੒ޙʹҾ͖ܧ͍ͰɺίʔϧόοΫΛ
 ઃఆ͠ͳ͓͢ ▸ Ұ౓Ωϟϯηϧͯ͠࠶ੜ੒ޙʹ΍Γͳ͓͢ 39 1.0 1.1 Cupcake Donut Eclair Froyo Gingerbread Honeycomb Ice Cream Sandwich Jelly Bean Kitkat Lollipop Marshmallow Nougat Oreo
  40. Retro/Prospective Android Application Loader ▸ Activity ͷϥΠϑαΠΫϧͱඇಉظॲཧͷϥΠϑαΠΫϧͷࠩҟΛϋϯυϧ͢Δ 40 1.0 1.1

    Cupcake Donut Eclair Froyo Gingerbread Honeycomb Ice Cream Sandwich Jelly Bean Kitkat Lollipop Marshmallow Nougat Oreo Activity LoaderManager Destroyed! Finish! Activity Loader Cache
  41. Retro/Prospective Android Application Loader public class MainActivity extends Activity implements

    LoaderCallbacks<Data> { public Loader<Data> onCreateLoader(int id, Bundle args) { if (id == 0) { return new MainLoader(); } else if (id == 1) { return new SecondLoader(); } else { throw new IllegalArgumentException(“invalid id”); } } public void onLoadFinished(Loader<Data> loader, Data data) { showData(data); } public void onLoaderReset(Loader<Data> loader) { } } 41 1.0 1.1 Cupcake Donut Eclair Froyo Gingerbread Honeycomb Ice Cream Sandwich Jelly Bean Kitkat Lollipop Marshmallow Nougat Oreo
  42. Retro/Prospective Android Application Loader public class MainActivity extends Activity implements

    LoaderCallbacks<Data> { public Loader<Data> onCreateLoader(int id, Bundle args) { if (id == 0) { return new MainLoader(); } else if (id == 1) { return new SecondLoader(); } else { throw new IllegalArgumentException(“invalid id”); } } public void onLoadFinished(Loader<Data> loader, Data data) { showData(data); } public void onLoaderReset(Loader<Data> loader) { } } 42 1.0 1.1 Cupcake Donut Eclair Froyo Gingerbread Honeycomb Ice Cream Sandwich Jelly Bean Kitkat Lollipop Marshmallow Nougat Oreo
  43. Retro/Prospective Android Application Loader public class MainActivity extends Activity implements

    LoaderCallbacks<Data> { @Override public Loader<Data> onCreateLoader(int id, Bundle args) { if (id == 0) { return new MainLoader(); } else if (id == 1) { return new SecondLoader(); } else { throw new IllegalArgumentException(“invalid id”); } } @Override public void onLoadFinished(Loader<Data> loader, Data data) { showData(data); } @Override public void onLoaderReset(Loader<Data> loader) { } } 43 1.0 1.1 Cupcake Donut Eclair Froyo Gingerbread Honeycomb Ice Cream Sandwich Jelly Bean Kitkat Lollipop Marshmallow Nougat Oreo
  44. Retro/Prospective Android Application Loader public class MainActivity extends Activity implements

    LoaderCallbacks<Data> { @Override public Loader<Data> onCreateLoader(int id, Bundle args) { if (id == 0) { return new MainLoader(); } else if (id == 1) { return new SecondLoader(); } else { throw new IllegalArgumentException(“invalid id”); } } @Override public void onLoadFinished(Loader<Data> loader, Data data) { showData(data); } @Override public void onLoaderReset(Loader<Data> loader) { } } 44 1.0 1.1 Cupcake Donut Eclair Froyo Gingerbread Honeycomb Ice Cream Sandwich Jelly Bean Kitkat Lollipop Marshmallow Nougat Oreo
  45. Retro/Prospective Android Application Loader public class MainActivity extends Activity implements

    LoaderCallbacks<Data> { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); LoaderManager loaderManager = getLoaderManager(); loaderManager.initLoader(0, new Bundle(), this); } } 45 1.0 1.1 Cupcake Donut Eclair Froyo Gingerbread Honeycomb Ice Cream Sandwich Jelly Bean Kitkat Lollipop Marshmallow Nougat Oreo
  46. Retro/Prospective Android Application Loader public class MainActivity extends Activity implements

    LoaderCallbacks<Data> { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); LoaderManager loaderManager = getLoaderManager(); loaderManager.initLoader(0, new Bundle(), this); } } 46 1.0 1.1 Cupcake Donut Eclair Froyo Gingerbread Honeycomb Ice Cream Sandwich Jelly Bean Kitkat Lollipop Marshmallow Nougat Oreo
  47. Retro/Prospective Android Application Fragment 47 1.0 1.1 Cupcake Donut Eclair

    Froyo Gingerbread Honeycomb Ice Cream Sandwich Jelly Bean Kitkat Lollipop Marshmallow Nougat Oreo
  48. Retro/Prospective Android Application Fragment ▸ ໨త ▸ ࢖͍·Θ͢͜ͱͷͰ͖Δ UI ͷ·ͱ·Γ

    ▸ UI Λ΋ͨͳ͍Ϟδϡʔϧ ▸ Activity ͷϥΠϑαΠΫϧͱಉظͯ͠ಈ͘ 48 1.0 1.1 Cupcake Donut Eclair Froyo Gingerbread Honeycomb Ice Cream Sandwich Jelly Bean Kitkat Lollipop Marshmallow Nougat Oreo
  49. Retro/Prospective Android Application Fragment 49 1.0 1.1 Cupcake Donut Eclair

    Froyo Gingerbread Honeycomb Ice Cream Sandwich Jelly Bean Kitkat Lollipop Marshmallow Nougat Oreo
  50. Retro/Prospective Android Application UI Λ·ͱΊΔ Fragment ▸ େ͖ͳը໘Ͱ͸ϚϧνϖΠϯ(λϒϨοτ) ▸ খ͞ͳը໘Ͱ͸υϩϫʔϝχϡʔ(ϋϯυηοτ)

    50 1.0 1.1 Cupcake Donut Eclair Froyo Gingerbread Honeycomb Ice Cream Sandwich Jelly Bean Kitkat Lollipop Marshmallow Nougat Oreo FRAGMENT A FRAGMENT B FRAGMENT B
  51. Retro/Prospective Android Application UI Λ·ͱΊΔ Fragment ▸ େ͖ͳը໘Ͱ͸ϚϧνϖΠϯ(λϒϨοτ) ▸ খ͞ͳը໘Ͱ͸υϩϫʔϝχϡʔ(ϋϯυηοτ)

    51 1.0 1.1 Cupcake Donut Eclair Froyo Gingerbread Honeycomb Ice Cream Sandwich Jelly Bean Kitkat Lollipop Marshmallow Nougat Oreo FRAGMENT A FRAGMENT B FRAGMENT B FRAGMENT A
  52. Retro/Prospective Android Application UI Λ࣋ͨͳ͍ Fragment ▸ setRetainInstance(true) ▸ Activity

    ͷ࠶ੜ੒Λ௒͑ͯσʔλΛอ͍࣋ͨ͠৔໘Ͱ࢖͏ 52 1.0 1.1 Cupcake Donut Eclair Froyo Gingerbread Honeycomb Ice Cream Sandwich Jelly Bean Kitkat Lollipop Marshmallow Nougat Oreo
  53. Retro/Prospective Android Application Fragment ▸ Do ✓ Fragment ੜ੒࣌ʹσʔλΛ౉͢ͱ͖͸ setArguments

    Λ࢖͏ ✓ ίʔϧόοΫ͸ Fragment#onAttach Ͱઃఆ͢Δ ▸ Don’t ✗ σʔλ΍ίʔϧόοΫΛ setter ΍ίϯετϥΫλͰઃఆ͢Δ 53 1.0 1.1 Cupcake Donut Eclair Froyo Gingerbread Honeycomb Ice Cream Sandwich Jelly Bean Kitkat Lollipop Marshmallow Nougat Oreo
  54. Retro/Prospective Android Application Support Libraries ▸ ৽͍͠ API Level ͷ

    API Λݹ͍ API Level ΁όοΫϙʔτ͢ΔϥΠϒϥϦ ▸ v4 Support Library, v7 AppCompat Library, etc… ▸ Fragment ͸ Support Libraries ʹؚ·ΕΔ΋ͷΛ࢖͏ ▸ όάϑΟΫε͕഑৴͞ΕΔ 54 1.0 1.1 Cupcake Donut Eclair Froyo Gingerbread Honeycomb Ice Cream Sandwich Jelly Bean Kitkat Lollipop Marshmallow Nougat Oreo
  55. Starting from Lollipop… 55

  56. Retro/Prospective Android Application Android 5.x (API Level 21 ~ 22)

    ▸ Material Design ▸ Android RunTime(ART) ▸ JobSchedulers and GcmNetworkManager(Firebase JobDispatcher) 56 1.0 1.1 Cupcake Donut Eclair Froyo Gingerbread Honeycomb Ice Cream Sandwich Jelly Bean Kitkat Lollipop Marshmallow Nougat Oreo
  57. Retro/Prospective Android Application JobSchedulers and GcmNetworkManager(Firebase JobDispatcher) ▸ ΞϓϦέʔγϣϯͷϓϩηε಺ͰδϣϒΛ࣮ߦ͢ΔͨΊͷϑϨʔϜϫʔΫ ▸

    όοΫάϥ΢ϯυͰಈ࡞͢Δ͞·͟·ͳॲཧͷ࣮ߦΛίϯτϩʔϧ͢Δ ▸ ঢ়گΛݟͯϑϨʔϜϫʔΫ͕Α͠ͳʹ࣮ߦλΠϛϯάΛݟܭΒͬͯ͘ΕΔ ▸ ઀ଓ͍ͯ͠ΔωοτϫʔΫͷछྨ(ैྔ՝͔ۚͲ͏͔ɺͳͲ) ▸ લճࣦഊ͔࣌ΒͷόοΫΦϑ 57 1.0 1.1 Cupcake Donut Eclair Froyo Gingerbread Honeycomb Ice Cream Sandwich Jelly Bean Kitkat Lollipop Marshmallow Nougat Oreo
  58. Retro/Prospective Android Application JobSchedulers and GcmNetworkManager(Firebase JobDispatcher) ▸ όοΫάϥ΢ϯυॲཧʹΑΔόοςϦʔফඅΛ཈͑ΔͨΊͷ͘͠Έ ▸

    Service ͕όοΫάϥ΢ϯυͰಈ࡞͚ͭͮ͠Δ͜ͱΛආ͚Δ ▸ ωοτϫʔΫ઀ଓ͕ྑ͘ͳ͍ঢ়گͰෆඞཁʹ௨৴ΛࢼΈΔ͜ͱΛආ͚Δ 58 1.0 1.1 Cupcake Donut Eclair Froyo Gingerbread Honeycomb Ice Cream Sandwich Jelly Bean Kitkat Lollipop Marshmallow Nougat Oreo
  59. Retro/Prospective Android Application Doze ▸ όοςϦʔফඅΛ཈͑ΔͨΊͷ͘͠Έୈೋ஄ ▸ ը໘͕෇͍͍ͯͳ͍ɾॆిதͰͳ͍࣌ʹൃಈ͢ΔϞʔυ ▸ ఆظతʹόοΫάϥ΢ϯυॲཧΛ࣮ߦՄೳͳׂ͕࣌ؒΓ౰ͯΒΕΔ

    ▸ ϝϯςφϯε΢Οϯυ΢ ▸ AlarmManager ΍ JobScheduler, SyncAdapter ͷॲཧ΋ӨڹΛड͚Δ ▸ WakeLock ΋ແࢹ 59 1.0 1.1 Cupcake Donut Eclair Froyo Gingerbread Honeycomb Ice Cream Sandwich Jelly Bean Kitkat Lollipop Marshmallow Nougat Oreo
  60. Retro/Prospective Android Application Doze Enhancements ▸ Marshmallow ͷ Doze ͸σόΠεΛ࣋ͪาؒ͘͸ൃಈ͠ͳ͔ͬͨ

    ▸ σόΠε͕੩ࢭதʹ Doze ͕ൃಈ͢Δͱ CPU ΋εϦʔϓ͢ΔΑ͏ʹͳͬͨ ▸ WakeLock ▸ AlarmManager ▸ GPS/WiFi Scan 60 1.0 1.1 Cupcake Donut Eclair Froyo Gingerbread Honeycomb Ice Cream Sandwich Jelly Bean Kitkat Lollipop Marshmallow Nougat Oreo
  61. Retro/Prospective Android Application Background Limits ▸ Execution Limits ͱ Location

    Limits ▸ Execution: Service ͱ Broadcast ͷ੍ݶ ▸ IntentService ΋ӨڹΛड͚Δ -> JobIntentService ▸ Location: Ґஔ৘ใͷ੍ݶ 61 1.0 1.1 Cupcake Donut Eclair Froyo Gingerbread Honeycomb Ice Cream Sandwich Jelly Bean Kitkat Lollipop Marshmallow Nougat Oreo
  62. Retro/Prospective Android Application چདྷͷ API ͷந৅Խ ▸ RecyclerView ▸ Architecture

    Components 62 1.0 1.1 Cupcake Donut Eclair Froyo Gingerbread Honeycomb Ice Cream Sandwich Jelly Bean Kitkat Lollipop Marshmallow Nougat Oreo
  63. Retro/Prospective Android Application RecyclerView ▸ ListView ΍ GridView ͷந৅Խ ▸

    ViewHolder ύλʔϯʹΑΔ Adapter ͷ࣮૷ ▸ ΧελϚΠζͷͨΊͷ API ▸ LayoutManager ▸ SnapHelper 63 1.0 1.1 Cupcake Donut Eclair Froyo Gingerbread Honeycomb Ice Cream Sandwich Jelly Bean Kitkat Lollipop Marshmallow Nougat Oreo
  64. Retro/Prospective Android Application ArchitectureComponents ▸ ϥΠϑαΠΫϧͷந৅Խ ▸ Activity ΍ Fragment,

    Service ͳͲ -> LifecyclerOwner ▸ ϥΠϑαΠΫϧʹ࿈ಈ͢΂͖Ϋϥε -> LifecycleObserver ▸ UI ʹඥͮ͘σʔλΛ؅ཧ͢ΔΫϥε -> ViewModel 64 1.0 1.1 Cupcake Donut Eclair Froyo Gingerbread Honeycomb Ice Cream Sandwich Jelly Bean Kitkat Lollipop Marshmallow Nougat Oreo
  65. Retro/Prospective Android Application ArchitectureComponents ▸ ϥΠϑαΠΫϧͷந৅Խ ▸ มԽ͠ଓ͚ΔσʔλͱϥΠϑαΠΫϧͷඥ෇͚ -> LiveData

    ▸ େ͖ͳσʔληοτͷϖʔδωʔγϣϯ -> Paging Library 65 1.0 1.1 Cupcake Donut Eclair Froyo Gingerbread Honeycomb Ice Cream Sandwich Jelly Bean Kitkat Lollipop Marshmallow Nougat Oreo
  66. Retro/Prospective Android Application ArchitectureComponents public class MainActivity extends AppCompatActivity {

    private MainViewModel mViewModel; private TextView mTextView; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mTextView = findViewById(R.id.hello_world); mViewModel = ViewModelProviders.of(this).get(MainViewModel.class); mTextView.setText(mViewModel.getSomething()); } } 66 1.0 1.1 Cupcake Donut Eclair Froyo Gingerbread Honeycomb Ice Cream Sandwich Jelly Bean Kitkat Lollipop Marshmallow Nougat Oreo
  67. Retro/Prospective Android Application ArchitectureComponents public class MainActivity extends AppCompatActivity {

    private MainViewModel mViewModel; private TextView mTextView; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mTextView = findViewById(R.id.hello_world); mViewModel = ViewModelProviders.of(this).get(MainViewModel.class); mTextView.setText(mViewModel.getSomething()); } } 67 1.0 1.1 Cupcake Donut Eclair Froyo Gingerbread Honeycomb Ice Cream Sandwich Jelly Bean Kitkat Lollipop Marshmallow Nougat Oreo
  68. Retro/Prospective Android Application ArchitectureComponents public class MainActivity extends AppCompatActivity {

    private MainViewModel mViewModel; private TextView mTextView; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mTextView = findViewById(R.id.hello_world); mViewModel = ViewModelProviders.of(this).get(MainViewModel.class); mTextView.setText(mViewModel.getSomething()); } } 68 1.0 1.1 Cupcake Donut Eclair Froyo Gingerbread Honeycomb Ice Cream Sandwich Jelly Bean Kitkat Lollipop Marshmallow Nougat Oreo
  69. Retro/Prospective Android Application ArchitectureComponents public class MainViewModel extends AndroidViewModel {

    public MainViewModel(Application application) { super(application); } public String getSomething() { return “Hello World!”; } @Override // Automatically called when Activity is destroyed public void onCleared() { super.onCleared(); Log.d(“MainViewModel”, “onCleared!”); } } 69 1.0 1.1 Cupcake Donut Eclair Froyo Gingerbread Honeycomb Ice Cream Sandwich Jelly Bean Kitkat Lollipop Marshmallow Nougat Oreo
  70. Retro/Prospective Android Application ArchitectureComponents public class MainViewModel extends AndroidViewModel {

    public MainViewModel(Application application) { super(application); } public String getSomething() { return “Hello World!”; } @Override // Automatically called when Activity is destroyed public void onCleared() { super.onCleared(); Log.d(“MainViewModel”, “onCleared!”); } } 70 1.0 1.1 Cupcake Donut Eclair Froyo Gingerbread Honeycomb Ice Cream Sandwich Jelly Bean Kitkat Lollipop Marshmallow Nougat Oreo
  71. Retro/Prospective Android Application ArchitectureComponents public class MainViewModel extends AndroidViewModel {

    public MainViewModel(Application application) { super(application); } public String getSomething() { return “Hello World!”; } @Override // Automatically called when Activity is destroyed public void onCleared() { super.onCleared(); Log.d(“MainViewModel”, “onCleared!”); } } 71 1.0 1.1 Cupcake Donut Eclair Froyo Gingerbread Honeycomb Ice Cream Sandwich Jelly Bean Kitkat Lollipop Marshmallow Nougat Oreo
  72. Retro/Prospective Android Application ArchitectureComponents public class MainViewModel extends AndroidViewModel {

    public MainViewModel(Application application) { super(application); } public String getSomething() { return “Hello World!”; } @Override // Automatically called when Activity is destroyed public void onCleared() { super.onCleared(); Log.d(“MainViewModel”, “onCleared!”); } } 72 1.0 1.1 Cupcake Donut Eclair Froyo Gingerbread Honeycomb Ice Cream Sandwich Jelly Bean Kitkat Lollipop Marshmallow Nougat Oreo
  73. ·ͱΊ 73

  74. Retro/Prospective Android Application ·ͱΊ ▸ API ͷϕʔε͸ 1.0 ͷࠒ͔Β΄΅͓ͳ͡ ▸

    ը໘΍ඇಉظॲཧͷϥΠϑαΠΫϧ͸΄΅มΘ͍ͬͯͳ͍ ▸ Activity, Fragment ▸ Thread with Handler -> AsyncTask -> AsyncTaskLoader ▸ ୺຤ͷਐԽʹͱ΋ͳͬͯΞϓϦ΋ਐԽ͍ͯ͠ΔͷͰলϝϞϦ͸ࠓͳ͓ॏཁ ▸ JobScheduler and GcmNetworkManager(Firebase JobDispatcher) 74 1.0 1.1 Cupcake Donut Eclair Froyo Gingerbread Honeycomb Ice Cream Sandwich Jelly Bean Kitkat Lollipop Marshmallow Nougat Oreo
  75. Retro/Prospective Android Application ·ͱΊ ▸ API ͷෳࡶ͞ͱ෇͖߹͏ํ๏͕૿͖͑ͯͨ ▸ ඇಉظॲཧͷந৅Խ: AsyncTask,

    AsyncTaskLoader ▸ ϥΠϑαΠΫϧͷந৅Խ: ArchitectureComponents ▸ View ͷந৅Խ: RecyclerView ▸ RxJava ΍ͦΕΛϕʔεʹͨ͠ Flux ͳͲɺ୅ସखஈ΋͋Δ 75 1.0 1.1 Cupcake Donut Eclair Froyo Gingerbread Honeycomb Ice Cream Sandwich Jelly Bean Kitkat Lollipop Marshmallow Nougat Oreo
  76. Keishin Yokomaku (@KeithYokoma) - DevFest Tokyo 2017 Android 1.5~8.0 Walkthrough

    - Retro/Prospective Android Application Development -