Why does Android require a Context to access a resource? -


i why android requires pass context object when trying view example, show toast, etc.

however, don't point requiring access resources shared different contexts in application.

i several times found myself trying access resource utility class using static method or along lines, , find pretty annoying require passing of context param.

i fail see go south this.

from official documentation :

interface global information application environment. abstract class implementation provided android system. allows access application-specific resources , classes, up-calls application-level operations such launching activities, broadcasting , receiving intents, etc.

in clear, context middleman between telephone resource, , code. , seems logical, cannot access everywhere.

the reason can access context in activity , application classes, because both derives context :

java.lang.object

↳ android.content.context    ↳ android.content.contextwrapper        ↳ android.view.contextthemewrapper            ↳ android.app.activity 

Comments

Popular posts from this blog

matlab - "Contour not rendered for non-finite ZData" -

delphi - Indy UDP Read Contents of Adata -

javascript - Any ideas when Firefox is likely to implement lengthAdjust and textLength? -