How to display a toast message in only one activity?
<p>In an application I am developing I have some code that attempts to submit information to the internet. If the connection can not be made, I pop up a toast message instructing the user to check the network connection.</p>

<pre><code>  Toast.makeText(getApplicationContext(), "Check network connection.", Toast.LENGTH_SHORT).show();
</code></pre>

<p>The problem I have is the toast message comes up no matter what the user is looking at! Even if the user is in a different app and my app is running in the background! This is not the desired behavior as I send a notification to the user if network activity fails. I only want the toast message to appear if the user is in the activity that is generating the network activity. Is there a way to do this? </p>

<p>If this is not possible my idea was to just put some kind of visual element in my activity - rather than display a toast message.</p>

<p>Thank You!</p>