Different toast messages in Android

1.3k Views Asked by At

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.

2

There are 2 best solutions below

0
On BEST ANSWER

Your application is themed by Samsungs' TouchWiz UI

0
On

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