2
0

More than 1 year has passed since last update.

[Android]第二回Contextを掘り下げるの会

Posted at

はじめに

前回は、ApplicationContextとActivityContextの違いについて掘り下げたので、今回はそもそもContextは何をしているのか?について掘り下げたいと思います。

ドキュメントより

Interface to global information about an application environment.

ドキュメント先輩のお言葉。
グローバル情報へのインターフェース的な意味があります。
ActivityもApplicationもContextを継承しているので、何となくわかったような気がする。

何をしているのか?

ApplicationContextとActivityContexgの二種類に分けてみていきます。

ApplicationContext

  • Resourceへのアクセス
  • Serviceを開始する
  • Serviceをバインドする
  • ブロードキャストを送信する
  • ブロードキャストレシーバーを受信する

ActivityContext

  • Resourceへのアクセス
  • Serviceを開始する
  • Servieをバインドする
  • ダイアログを表示させる
  • Activityを開始する
  • Fragmantを展開する

ここでいうリソースとは、画像や文字リソース、レイアウトファイルなどの静的コンテンツです。
Androidでは、これらを独立して保持する必要があります。

おわりに

いかがだったでしょうか。
あまり関わり過ぎると、沼にハマるのでこれくらいにしてやっぞ。

参考

2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0