HOWTO Context

Put your problem here if it does not fit any of the other categories.

HOWTO Context

Postby fbarnard » Mon Nov 08, 2010 12:56 pm

Hi

I reasonably new with android and its been a while since i did java. I got into it wrote about 10 or so apps ranging from one button textview until a webserver. Know my question is is there not a better way of dealing with the Context object. This passing the object around seems a littlebit wrong. And its sort of a inportant object you use it almost everywhere.

thanks
fbarnard
Developer
Developer
 
Posts: 44
Joined: Tue Jun 15, 2010 12:31 pm

Top

Re: HOWTO Context

Postby blundell » Wed Nov 10, 2010 5:12 pm

Nope that's what you have to do, pass it round :-)

You don't need to pass it between activities as each activity has it's own context.
There is also getApplicationContext() for any class extending Activity.

It allows your code to know where it is an where it can draw!
User avatar
blundell
Master Developer
Master Developer
 
Posts: 1610
Joined: Tue Nov 18, 2008 12:58 pm
Location: UK

Re: HOWTO Context

Postby fbarnard » Thu Nov 11, 2010 1:35 pm

Yeah thought to. Its a bit eecky saying the least
fbarnard
Developer
Developer
 
Posts: 44
Joined: Tue Jun 15, 2010 12:31 pm

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: No registered users and 24 guests