lundi 18 avril 2016

Android: PHP in background Thread

My question maybe unheard of or may even be impractical. But, I believe it is practical and acceptable.

Problem: PHP request and response in background thread.

Problem constraints:

  1. You know it uses POST method.
  2. It has two fields fname and lname as html ids that need to be filled.
  3. You get response in the same page i.e. index.php .

Pseudocode to solve the problem:

  1. Open the website in background. Something like openURL("xyz(dot)com");
  2. Read the data sent in html format.
  3. Change the value of the fields fname and lname to required fields "Allen" and "Walker."
  4. Now, submit the fields back to the server. ( Page has a submit button.)

Note: PHP code has a standard if-else check to check for those values. If the field is properly set, it then says "Success" else "Failed"

  1. Again, get the response sent by the server.
  2. Check if "Success" was returned.

  3. If "success" was returned, UPDATE UI thread for saying "JOB done". Else, "Job failed."

Note: I am not talking about using a WebView. Everything happens via a service or AsyncTask.


Now, this is a simple question, and any ideas or a direction is acceptable.

So, to recap. You have to open a webpage in background, change its field, submit it back and then get the response.


I know we can open a website and get its content. But, I would also like to know if what I said is possible or not. And, I know it is possible. And, that I only lack the knowledge on Java Web API, could you please guide me on this.

Thank You. And, Have a Good day!




Aucun commentaire:

Enregistrer un commentaire