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



How disable "1101- Unable to get a response" error message from Web component?


Hello, anyone know how i can disable the "1101 " error of the web component, if my phone is not connected to internet?

--
use the Screen.ErrorOccurred event to catch that error, see also

--

Web got.file on device give error 1101 but in emulator work good


I try to download a file with the block web Got.file and when i try tthe code with Companion on my phoe it work good, when i build the apk and i try to download it i receive the error message 1101.
I think it's a problem of App Inventor Building cose i have try to do a new app just with a button for download a file and i receive the same error 1101, just building the apk, on companion it work...
The same code in the same app work when i have try it with AI1 worked good.
Sorry for my bad english, but i really need some help...
(the code is the same of this tutorial page: http://puravidaapps.com/filedownload.php)
thank you for your helps.

--
does the example work for you without modifications?
you can download it here Download aia file for App Inventor 2

--
I have the same problem, when web Got File startet he say cant find file i recive error message 1101.
And i added new screen in existing app and when i start him he crash but work fine under emulator

--
@Vedran: It would really help if you provided a screenshot of your relevant blocks, so we can see what you are trying to do, and where the problem may be.

--
i have dowloaded your .aia file, i have loaded it in my AI2 and i have build the app...
Same problem, Ai2 give me error 1101...
Now i think is a issue of App Inventor builder...
This aia file work in your devices?

--
I just tested the example successfully
probably an issue with your internet connection?
--
sorry but have you tested it with an emulator or on a device with the apk? Cose on AI2 connected with Ai Companion at my phone it work, just when i build the apk and i install it on my device it don't work, and the connection is the same.. For try it i have try to connect me to a friend's wifi and with my 3g phone connection too... Nothing, i have the same problem.. (error 1101)
Would you try to reload your aia file in AI2 and (re)build the apk and test it on a device please?
Thank you for your attention.

--
you are right, downloading a file using the web component doesn't work anymore after building the app.

logcat output 

I also tried to download an image from my own web server, this also failed! 

@MIT: please find an example project attached. Just build it and run the apk file, then click the get button and the error 1101 appears. Thank you.
--
Thank you Taifun for your help

--
Thanks.  Any idea when this started happening?

--
I just built the example on the extension test server and it works fine, which means, it's another V145 issue... 

--
I'm looking into this now...

--
I have found and fixed this bug. It should be in tomorrow's release.

The problem was caused by our updating minSdk from 3 to 4. The Web component writes to external storage (aka the sdcard) which requires READ_EXTERNAL_STORAGE and WRITE_EXTERNAL_STORAGE. However it didn't have those permissions. It used to work because those permissions were introduced with API 4. So when we set minSdk to 3, they were implicitly granted. But when we updating things to minSdk of 4, things broke.

The Companion worked because it has those permissions because they were added to the File component at some point and the Companion has all components built in so it gets all the permissions.

--
We just deployed release nb145b which fixes this issue.

--
Yes now it work, thank you so much for your helps.
--