2017년 4월 27일 목요일

Check Internet Connection In App Inventor


Checking connection is very easy. You can use a Web component and try connecting to a website. Google.com is a very good candidate for that since it’s very unusual for google server to be down. Below is a snippet where I have a button and when you click the button, it tries to connect to google.com. You can download the project CheckConnection and try changing the google url to something that doesn’t exist and see the result. Say if you set the value of the variable googleUrl to http://www.google.com/1234/5678, you will have a 404 error. If the responseCode sent from the server is 200, that means you have connection.

For a list of response codes and what they mean, see HTTP status codes.



Here’s the project source – CheckConnection



댓글 없음:

댓글 쓰기