How to stay in the activity with out force-closing the app
<p>In my app when I click on a menu button it will go to an activity where I will load data and images from a remote server to a custom list view. The problem is if the WiFi is switched off, I'm getting a crash in the second activity.  I have put the code in the try catch block and set the adapter to null in the catch section.So when i click the button it will go the activity and if the WiFi is off, since i set adapter = null in the catch activity will be shown with out a list view. How  can i stay in the menu screen with out getting a crash. Any idea?</p>

<pre><code>        Intent mainIntent = new Intent( SplashScreenActivity.this, GiftListActivity.class );
        SplashScreenActivity.this.startActivity( mainIntent );
</code></pre>

<p>This is my call to the second activity.</p>

<pre><code>try{
    adapter = new GiftJewelryListAdapter(GiftListActivity.this, giftlist);
    itemsListView.setAdapter(adapter);
}
catch(Exception e){
    adapter=null;
    MyAlertDialog.ShowAlertDialog(GiftJewelryListActivity.this, "", "Check Network Connection", "OK");
}
</code></pre>

<p>I want to stay in the activity from which i called, after showing the message "check network connection".What change should i do here?</p>
