is there way to access main context without don't sent context? on android -


i made custom class called "customclass".

basically, send main context follow in

in mainactivity,

customclass cclass = new customclass(this); 

in customclass,

public customclass(context context){   this.context = context; } 

but, don't want send context in mainactivity.

just call constructor in mainactivity,

customclass cclass = new customclass(); 

and customclass got context of mainactivity.

does know how this?

oh!, don't want these way. such write

android:name ="com.example.customclass" 

in manifest.xml

make application baseapplication have make method.

then add mainactivity in it. , use in customclass.

or can use application context instead of mainactivity.

depends on using what.


Comments

Popular posts from this blog

python - Operations inside variables -

Generic Map Parameter java -

arrays - What causes a java.lang.ArrayIndexOutOfBoundsException and how do I prevent it? -