Tengo en mi app un sitio donde muestro una pagina web. Me gustaria en el caso de no haber conexion de datos, sea por wifi o red, que me mostrara otra cosa en vez del cartel de android diciendo que no hay conexion. Cual es el metodo para obtener ese dato de manera de poder con un IF hacer una cosa o la otra?
Update 29/8/2018: i uploaded new version without FIREBASE to help who dont need B4A is very good app to build Android app. I want to use it built app same as Android Studio, so i make a "BASE" app to make more apps from it Since 8/2018, you must set target SDK is 26, so many changes to your...
Sub Process_Globals
Dim InternetConnected As Boolean, ph As PhoneEvents
End Sub
Sub Service_Create
ph.Initialize("ph")
End Sub
Sub ph_ConnectivityChanged (NetworkType As String, State As String, Intent As Intent)
If State = "CONNECTED" Then
InternetConnected = True
Else
InternetConnected = False
End If
End Sub
y luego leo InternetConnected desde donde necesite. Muchas gracias, sencillo y funciona OK.
Sub Process_Globals
Dim InternetConnected As Boolean, ph As PhoneEvents
End Sub
Sub Service_Create
ph.Initialize("ph")
End Sub
Sub ph_ConnectivityChanged (NetworkType As String, State As String, Intent As Intent)
If State = "CONNECTED" Then
InternetConnected = True
Else
InternetConnected = False
End If
End Sub
y luego leo InternetConnected desde donde necesite. Muchas gracias, sencillo y funciona OK.
Hi guys I need help to check internet connection is ON or OFF I try eks. If CheckConnection Then Msgbox("You connected internet", "OK") Else Msgbox("You didn't connect internet", "Error") End If Sub CheckConnection As Boolean Dim p As Phone If...
Ok, entendido, en cualquier caso para lo que quiero me vale. Entiendo que si estoy en una red local sin datos externos me aparecera como "conectado" aunque no tenga internet. Gracias.
No sabia que existía eso yo siempre hago un petición a San Google el santo de mi devoción y siempre me ha funcionado sin problemas
B4X:
Sub ConexionInternet() As ResumableSub
Dim j As HttpJob
j.Initialize("", Me) 'name is empty as it is no longer needed
j.Download("http://www.google.com")
j.GetRequest.Timeout = 3000
Log(j.GetRequest.Timeout)
Wait For (j) JobDone(j As HttpJob)
If j.Success Then
MsgboxAsync("Conectado a Internet","Felicitaciones!!!")
Else
MsgboxAsync("Verifique Su Conexion a Internet","Advertencia!!!")
Wait For MsgBox_Result (Result As Int)
If Result = DialogResponse.POSITIVE Then
ExitApplication
End If
End If
j.Release
End Sub