How to translate this code to B4A

Qbetechmark

Member
Licensed User
Longtime User
Hi all, I have part of code from eclipse like this, and how to write down HttpPost on B4A :

B4X:
       String url_data_insert = "http://192.168.0.10/testandroid/insert.php";
           HttpClient httpClient = new DefaultHttpClient();
           HttpPost httpPost = HttpPost(url_data_insert);
           ArrayList<NameValuePair> param = new ArrayList<NameValuePair>();
           param.add(new BasicNameValuePair("username", editUser.getText().toString()));
           param.add(new BasicNameValuePair("password", editPass.getText().toString()));
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
Here:
B4X:
Sub Process_Globals
   Dim hc As HttpClient
End Sub

Sub Globals
End Sub

Sub Activity_Create(FirstTime As Boolean)
   If FirstTime Then
      hc.Initialize("hc")
   End If
   Dim post As HttpRequest
   Dim payload As String
   payload = "username=" & editUser.Text & "&password=" & editPass.Text
   post.InitializePost2("http://192...", payload.GetBytes("UTF8"))
   hc.Execute(post, 1)
End Sub
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…