Hi, I want to test if my activity has online access.  
I click a button to execute an activity (downloads a list of people from a 
database and populates it within the app) but I don't know where to put it?

When online activity is not detected I want the user to get a popup dialog box 
which says "No internet connectivity" and press OK.  

The app would return/stay at the same screen where the user pressed the button 
to execute the activity.

Where should I execute the isOnline code and how do I get the behavior I want?  
In the background task?

Thanks!

#code from google search stack overflow
private boolean isOnline()
    {
        try
        {
            ConnectivityManager cm = 
(ConnectivityManager)mContext.getSystemService(Context.CONNECTIVITY_SERVICE);
            return cm.getActiveNetworkInfo().isConnectedOrConnecting(); 
        }
        catch (Exception e)
        {
            return false;
        }
    }

-- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/android-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/android-developers/461d44a1-937b-4e93-8d2f-a699e5d8fc1c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to