I’m trying to write a basic toast example based on the volume buttons getting pressed up or down. I know it sounds silly and insane since most people avoid volume button things like its the plague. I am just wondering why by chance the “Context” area would be highlighted in red.
Maybe I’m missing a code some place but either way here is something along the lines of what I am working with:
public void onStopTrackingTouch(SeekBar seekBar) {
Toast.makeText(context, "Now stopped", Toast.LENGTH_LONG).show();
}
Also the code itself runs just not as it is intended to.
Because context is not defined in your class/activity , Better you use
or
or
Define a variable in your activity as
Context context;intialize it inonCreate()Method of activity ascontext = this;Then you can use context in Toast.makeText method.