How to check the internet is active or not?

Hello everyone ,
We can check internet is connected or not by network component .
Untitled
But how can we check either the internet connection is working or not ?

Just make a url connection to any page like google.com

If the response is okay (200) then you have a internet connection

9 Likes

You can call data from database backend your app. If data got then go next step. If data can’t get from database then you can show Dialog for net connection.

1 Like

Thankyou soo much :slight_smile:

I put in my application that if there is internet put a wifi icon and if there is no internet put the no wifi icon.

The blocks I use are those of the Network component.

When there is no internet automatically the component detects it and does what I put in the On.Disconnect event

foro network

2 Likes

I did what you said,
INTERNET
but getting this error,

It should have worked

use the Screen.ErrorOccured event to catch that error
Taifun

1 Like

You can try this method.

1 Like

grafik

I think that doesn’t work, because you can’t get response without Internet connection.

Why not simply something like this:

grafik

or what @pepocero suggested.

5 Likes

what I do works for me perfect … the network component has those events for something hehe I as soon as I loose internet I see the icon of no wifi

1 Like

unfortunately that does not help in this case.

I think that only check either internet is connected or not ,
But not internet has active connection or not.

You are getting this error because the Got Text event has not triggered because there is no internet connection. The “else” block will never work so simply use when Screen1.Error Occurred event to remove that error.

2 Likes

It´s true.

You can check this extension:

see the following link how to do it without using the Network component (which is not available in standard App Inventor) together with the Screen.ErrorOccurred event
https://www.imagnity.com/tutorials/app-inventor/check-internet-connection-in-app-inventor/

Taifun

3 Likes

Your Method Is Working :smile:

blocks (25)

Thanks Again For Solving My Problem :grin:

7 Likes

I used this in an app I’m making and it works perfectly.

7 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.