XverhelstX Well-Known Member Licensed User Longtime User Jun 29, 2011 #1 Hey everyone, I have finally succeeded in live-streaming to my webpage. Although, I work with HTTP POST Method and everytime the Timer runs of, it executes some Java Code that initializes a new HTTP Client and sends the data. This takes long and gives me sometimes an ANR message. Code: Copy HttpClient httpclient = new DefaultHttpClient(); HttpPost httppost = new HttpPost(WebServer); httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs)); HttpResponse response = httpclient.execute(httppost); HttpEntity entity = response.getEntity(); is = entity.getContent(); 1) Is there a way in B4A to keep a connection open between the device and the webserver or doesn't this really matter? 2) I use this: Code: Copy ArrayList<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(); nameValuePairs.add(new BasicNameValuePair("image",ba1)); nameValuePairs.add(new BasicNameValuePair("PHPProtect",FrameProtect)); in my Java to pass the data to my PHP code. Code: Copy if (isset($_REQUEST['PHPProtect'])) { $isProtected=$_REQUEST['PHPProtect']; How should I assign the correct data ba1 to image and FrameProtect to PHPProtect within the POST Method to send to the webserver. 3) How can you change the time out settings until a ANR message appears. Thanks, XverhelstX
Hey everyone, I have finally succeeded in live-streaming to my webpage. Although, I work with HTTP POST Method and everytime the Timer runs of, it executes some Java Code that initializes a new HTTP Client and sends the data. This takes long and gives me sometimes an ANR message. Code: Copy HttpClient httpclient = new DefaultHttpClient(); HttpPost httppost = new HttpPost(WebServer); httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs)); HttpResponse response = httpclient.execute(httppost); HttpEntity entity = response.getEntity(); is = entity.getContent(); 1) Is there a way in B4A to keep a connection open between the device and the webserver or doesn't this really matter? 2) I use this: Code: Copy ArrayList<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(); nameValuePairs.add(new BasicNameValuePair("image",ba1)); nameValuePairs.add(new BasicNameValuePair("PHPProtect",FrameProtect)); in my Java to pass the data to my PHP code. Code: Copy if (isset($_REQUEST['PHPProtect'])) { $isProtected=$_REQUEST['PHPProtect']; How should I assign the correct data ba1 to image and FrameProtect to PHPProtect within the POST Method to send to the webserver. 3) How can you change the time out settings until a ANR message appears. Thanks, XverhelstX
Erel B4X founder Staff member Licensed User Longtime User Jun 30, 2011 #2 Why aren't you using the regular Http library? Upvote 0
XverhelstX Well-Known Member Licensed User Longtime User Jun 30, 2011 #3 Because I have problems with this: Code: Copy ArrayList<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(); nameValuePairs.add(new BasicNameValuePair("image",ba1)); nameValuePairs.add(new BasicNameValuePair("PHPProtect",FrameProtect)); Don't know how to add those POST Methods to send them in B4A. With Stringbuilder, but how would they know that ba1 is a member of "image" and FrameProtect from PHPProtect. XverhelstX Upvote 0
Because I have problems with this: Code: Copy ArrayList<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(); nameValuePairs.add(new BasicNameValuePair("image",ba1)); nameValuePairs.add(new BasicNameValuePair("PHPProtect",FrameProtect)); Don't know how to add those POST Methods to send them in B4A. With Stringbuilder, but how would they know that ba1 is a member of "image" and FrameProtect from PHPProtect. XverhelstX
Erel B4X founder Staff member Licensed User Longtime User Jun 30, 2011 #4 The Http library is a complicated library that allows you to make calls in the background and thus avoid "ANR" dialogs. I recommend you to use it instead. If you are using HttpUtils then you can use HttpUtils.PostString("key1=value1&key2=value2&key3=value3") You should of course replace key and value with your parameters. Upvote 0
The Http library is a complicated library that allows you to make calls in the background and thus avoid "ANR" dialogs. I recommend you to use it instead. If you are using HttpUtils then you can use HttpUtils.PostString("key1=value1&key2=value2&key3=value3") You should of course replace key and value with your parameters.
XverhelstX Well-Known Member Licensed User Longtime User Jun 30, 2011 #5 Ok, thank you very much! So HTTPUtils belong to the HTTP Library, right? XverhelstX Upvote 0