Upgrade to Pro — share decks privately, control downloads, hide ads and more …

What The Context ?

What The Context ?

Slides from my talk at BLRDroid

Adnan A M

April 11, 2020
Tweet

More Decks by Adnan A M

Other Decks in Programming

Transcript

  1. Context ?!?? C nt xt s ur m gi !

    — Adnan A M B d 2
  2. W y o n ed on ex ? ✴ g

    u () ✴ g t () ✴ g e c () ✴ g () ✴ s X() -> S n c n (A y, S , B s e ) B d 3
  3. Types of Context ✴ A t C ✴ A y

    C ✴ B C ✴ T C ✴ t ✴ t B d 4
  4. A tu l yp s f on ex ✴ U

    C ✴ N -U C B d 5
  5. Understanding the Hierarchy Context | Context Wrapper +-----------+---------+ | |

    | Application Service ContextThemeWrapper | Activity B d 6
  6. UI Context ✴ A y - i (I e a

    y) ✴ F t - g e () ✴ V - g e () B d 9
  7. Non UI Context ✴ A y - g i C

    () ✴ S - g i C () / i (I e s ) ✴ C - g i C () ✴ B s R r - C p B d 10
  8. Application Context ✴ S o I e w h m

    p ✴ g i C () ✴ N C (L L ) B d 13
  9. Activity/Service Context ✴ U I e e a y/s ✴

    t ✴ A y C - C ✴ S C - o C B d 14
  10. Broadcast Receiver Context ✴ U I e e c ✴

    c p a t ✴ N C ✴ Y e a R r c t w a r r e () n b v () d d B d 15
  11. Base Context ✴ T d e i n h C

    ✴ C e l c ✴ C o d u a a e () h C W B d 16
  12. What #2 !!! ??? class SimpleSingleton { private static SimpleSingleton

    sInstance; private Context mContext; public static SimpleSingleton getInstance(Context context) { if (sInstance == null) { sInstance = new SimpleSingleton(context); } return sInstance; } private SimpleSingleton(Context context) { mContext = context; } } B d 19
  13. Oh Wow #1 !!! val contextThemeWrapper = ContextThemeWrapper(this, R.style.YOUR_THEME) val

    builder = AlertDialog.Builder(contextThemeWrapper) builder.show() B d 21
  14. Deciding Between UI & Non UI Context ✴ D o

    e a r s ? --> C ✴ L L o O o --> o C ✴ N r ? --> B t o C B d 25
  15. References ✴ W C S I s - l M

    a ✴ M n A C - G K ✴ C , a C - v S B d 26