Search code examples
androidsoundpool

what exactly does the "context" mean? For soundPool.load int load(Context context, int resId, int priority)


Recently I am trying to use SoundPool play some simple sound effect in my app

but unfortunately it doesn't work and app crash in AVD

what exactly does the "context" mean?

totally clueless

thanks in advance


Solution

  • Any context allows access to application-specific resources and classes, as well as up-calls for application-level operations such as launching activities, broadcasting and receiving intents, etc.

    Normally you can use this.YourClassName as context.

    Eg: soundID = soundPool.load(this.MainActivity, R.raw.sound1, 1);