Share
Embed
Android 1.5 - 8.0 Walk through - Retro/Prospective Android Application Development
Keishin Yokomaku
October 09, 2017
Annual Pro sale · Save $30
Have presentations of your own?
Share with private links, password protection, and more control over your work.
Transcript
76 slides
-
Android 1.5~8.0 Walkthrough - Retro/Prospective Android Application Development - Keishin
Yokomaku (@KeithYokoma) - DevFest Tokyo 2017 -
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 -
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 -
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 -
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 -
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 -
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 -
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 -
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 -
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 -
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 -
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 -
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 -
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 -
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 -
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 -
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 -
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 -
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 -
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 -
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 -
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! -
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 -
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 -
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 -
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 -
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 -
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 -
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 -
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 -
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 -
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 -
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 -
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 -
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 -
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 -
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 -
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 -
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 -
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 -
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 -
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 -
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 -
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 -
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 -
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 -
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 -
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 -
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 -
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 -
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 -
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 -
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 -
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 -
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 -
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 -
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 -
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 -
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 -
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 -
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 -
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 -
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 -
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 -
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 -
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 -
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 -
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 -
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 -
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 -
Keishin Yokomaku (@KeithYokoma) - DevFest Tokyo 2017 Android 1.5~8.0 Walkthrough
- Retro/Prospective Android Application Development -