Thanks but I needed more specifics. I ended up putting it in onResume
because the user needs to be able to click on the popup.

On Oct 3, 2016 23:02, "sardar khan" <[email protected]> wrote:

> check isOnline before getting data from internet if its true get the data
> from internet if not redirect back to user.
>
> On Tue, Oct 4, 2016 at 1:24 AM, Aaron D <[email protected]> wrote:
>
>> 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/ms
>> gid/android-developers/461d44a1-937b-4e93-8d2f-a699e5d8fc1c%
>> 40googlegroups.com
>> <https://groups.google.com/d/msgid/android-developers/461d44a1-937b-4e93-8d2f-a699e5d8fc1c%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Android Developers" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/
> topic/android-developers/JUUBpcWIZ5I/unsubscribe.
> To unsubscribe from this group and all its topics, 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/CABHzXARDmcqH--R9K1DQVeg6aKHhUcOCm6_
> k8B1pOuXTBSeaLg%40mail.gmail.com
> <https://groups.google.com/d/msgid/android-developers/CABHzXARDmcqH--R9K1DQVeg6aKHhUcOCm6_k8B1pOuXTBSeaLg%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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/CAFY%2BPo8JBvNgpnCHJkF4CVQDDzYMdmBg40QZ4Kua%2BMwKQQBVaw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to