I am using android media player class for playing notification sound in my android Application.
MediaPlayer player = MediaPlayer.create(getApplicationContext
I always do similar thing with a modified version of Singleton Pattern. Since context is needed everywhere in Android, I pass the context to the instance:
public class Asset{
public static Asset(Context context);
}
You can also have different singleton across different context scope, in this implementation, for example:
private static Hashtable instances;
public static Asset(Context context){
if (!instances.containKey(context)){
instances.put(context, new Asset(context));
return instances.get(context);
}
The advantage of this compare to classic singleton, is you can define the scope of your singletons. Sometimes you just need the instance stay in same Activity, but second Activity may have different instance. If you need it across different Activity, you just need to pass context.getApplicationContext().