Is one action = one context?

I am embarrassed to distinguish between context and activity. what is the context? Does the context have one action? will the context change if the action is changed?

I have a game that has multiple activity. every action for every part, splash screen, menu, game screen, etc. The problem is that I have one single SoundManager that uses soundpool as a sound player. I want to load every sound into a splashscreen. But after I look at it again, what about the context?

public void loadSound(Context context, int resId, String name) { int id = sounds.load(context, resId, priority) } 

if I load sounds into Activity SplashScreen, how can I play sound in GameScreen Activity? different context right?

+7
android android-activity
Mar 28 '11 at 3:24
source share
1 answer

Per: http://android-developers.blogspot.com/2009/01/avoiding-memory-leaks.html

In Android, context is used for many, but mainly for downloading and accessing resources. This is why all widgets get the Context parameter in their constructor. In a regular Android Application, there are usually two kinds of Context, Activity and Application.

And from Android docs :

Allows application and class resources, as well as application-level operations, such as launching, translating and receiving intentions, etc.

Typically, each action will have its own Context, and the application itself will have a context.

+8
Mar 28 '11 at 4:10
source share



All Articles