How to properly replace toast message with alert Dialog : I am new to android development and am working on a audio stream app. I need help on something urgently. I initially put a toast message to notify users when an error occurred while streaming audio service. However, i wanted to replace it with an alert dialog. But i have been getting an error.

Here is my previous code:

    public boolean onError(MediaPlayer mp, int what, int extra) {
            Toast.makeText(this, "There was an error playing the stream, Check your network connection", Toast.LENGTH_LONG).show();
            mediaPlayer.reset();
            return false;
        }

Here is the updated one which throws an error:



