1

In my Android application I get two different types of Toast message by giving getApplicationContext() and MainActivity.this

Method 1:

Toast.makeText(getApplicationContext(),"No more items.", Toast.LENGTH_LONG).show();

produce the following output:

enter image description here

Method 2:

Toast.makeText(MainActivity.this,"No more items.", Toast.LENGTH_LONG).show();

second method produce the following toast message which differ from the first one.

enter image description here

I do not know the reason between getApplicationContext() and MainActivity.this for producing two different toast messages. please share reason behind the difference.

I run under Android Kitkat 4.4.2 in Samsung S4.

M.A.Murali
  • 9,988
  • 36
  • 105
  • 182

2 Answers2

3

getapplication context return the context of the application which remain same throughout the application. But .this context returns the context specific to the activity.

Mark Henry
  • 255
  • 3
  • 8
1

Your application is themed by Samsungs' TouchWiz UI

Emre Aktürk
  • 3,306
  • 2
  • 18
  • 30