Try posting your code here, then we can help you out more
Sent from my DROIDX
Hi try putting your code between 'code' tags as it makes reading the code much easier.
Sub Process_Globals
Dim hc As HttpClient
Dim PLAYER_LIST As Int
PLAYER_LIST = 1
End Sub
Sub Globals
Type TwoLines (First As String, Second As String)
Dim ListView1 As ListView
End Sub
Sub Activity_Create(FirstTime As Boolean)
If FirstTime Then
hc.Initialize("hc")
End If
Activity.LoadLayout("HighScores")
FetchCountriesList
End Sub
Sub FetchCountriesList
ProgressDialogShow("Fetching list of countries")
'Gets all the available countries
ExecuteRemoteQuery("SELECT PlayerName, HighScore FROM HighScores ORDER BY HighScore", PLAYER_LIST)
End Sub
Sub ExecuteRemoteQuery(Query As String, TaskId As Int)
Dim req As HttpRequest
req.InitializePost2("http://localhost/HighScores.php", Query.GetBytes("UTF8"))
hc.Execute(req, TaskId)
End Sub
Sub hc_ResponseError (Response As HttpResponse, Reason As String, StatusCode As Int, TaskId As Int)
Log("Error: " & Reason & ", StatusCode: " & StatusCode)
If Response <> Null Then
Log(Response.GetString("UTF8"))
Response.Release
End If
ProgressDialogHide
End Sub
Sub hc_ResponseSuccess (Response As HttpResponse, TaskId As Int)
Dim res As String
res = Response.GetString("UTF8")
Log("Response from server: " & res)
Dim parser As JSONParser
parser.Initialize(res)
Select TaskId
Case PLAYER_LIST
Dim players As List
players = parser.NextArray 'returns a list with maps
For i = 0 To 4
Dim m As Map
m = players.Get(i)
'We are using a custom type named TwoLines (declared in Sub Globals).
'It allows us to later get the two values when the user presses on an item.
Dim tl As TwoLines
tl.First = m.Get("PlayerName")
tl.Second = m.Get("HighScore")
ListView1.AddTwoLines2(tl.First, tl.Second, tl)
Next
ProgressDialogHide
End Select
Response.Release
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
http://localhost points to the current device / emulator.
I guess that you want to connect to your desktop computer. You should use its IP instead.
You can find the IP by calling IPConfig from the command line.
Firewalls usually block incoming connections. Make sure that your firewall allows incoming connections on port 80.
req.InitializePost2("http://localhost/HighScores.php", Query.GetBytes("UTF8"))
req.InitializePost2("http://xxx.xxx.x.xxx/HighScores.php", Query.GetBytes("UTF8"))
It should be done in your server configuration.
This is a valid question. The answer is simple. Currently you don't have any HTTP (web) server running.
You should first install a web server. Google for "wamp".
As I previously wrote, http://localhost points to the current device. I guess that you are using the emulator. In that case you are trying to call to a server hosted in the emulator (which doesn't exist).
See this link for more information about the emulator: Using the Android Emulator | Android Developers
There is an IP address which you can use to access the desktop localhost.
req.InitializePost2("http://127.0.0.1/HighScores.php", Query.GetBytes("UTF8"))
req.InitializePost2("94.170.229.51/HighScores.php", Query.GetBytes("UTF8"))
http://localhost points to the current device / emulator.
I guess that you want to connect to your desktop computer. You should use its IP instead.
You can find the IP by calling IPConfig from the command line.
Firewalls usually block incoming connections. Make sure that your firewall allows incoming connections on port 80.
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?