• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Can I use application context to create a view

I am using activity context to create views and I found that we can use application context as well to create them then what is the difference between them. What are the advantages and disadvantages in terms of memory and performance.

Previous code inside activity's onCreate() : TextView v = new TextView(this);

New code inside activity's onCreate() : TextView v = new TextView(getApplicationContext)

On addition of this when I see hprof dump I found that after doing remvoewAllViews from parent view it is not showing this TextView as reference in activity but for old code it was showing.

Please advice what to use when.

Thanks, Pratik
 
Back
Top Bottom