D
D
Dave2016-01-12 19:21:29
Java
Dave, 2016-01-12 19:21:29

How to submit a form through android application?

In HTML, you can submit a form to another site by passing in data, something like this:

<form method="POST" action="http://my-server.com/parser.php">

    <input type="text" name="name" value="Test" />
    <input type="text" name="age" value="10" />
    
    <button type="submit">Send</button>
</form>

Accordingly, on the server, in the parser.php file, I can accept the transferred data (in this case, it is name and age).
Question:
Is it possible in an Android application to similarly submit a form in this way?
If not, is it possible to somehow emulate it?
PS.
No need to write code, just advise where you can read how to do it. I have not found anything sane to this moment.

Answer the question

In order to leave comments, you need to log in

4 answer(s)
V
VZVZ, 2016-01-12
@djay

It is possible, as many as 2 ways:
1) Open the form in a standard browser engine - WebView - as in a normal browser, only in your Activity (OPTIONAL) and under the control of your application.
bsb.info/java/android/browsers/webview.html
2) HTTP request is a more low-level method, does not require user participation, works faster, is universal, but also heavier.
If you have someone else's site / service and you need to simulate local requests, then you need to take a sniffer, for example, Fiddler, and first experiment with desktop Java (for convenience), and then transfer the code to an Android application and test it.
There are also intermediate options for different tasks.
For example, jsoup is not exactly a browser engine, does not execute JS, does not provide any rendering, but makes a GET request and renders HTML into a DOM tree that can be programmatically manipulated.

A
aol-nnov, 2016-01-12
@aol-nnov

anything from HttpUrlConnection to OkHttp + Robospice
> advise only where you can read how to do it,
the very soft here.

S
sivabur, 2016-01-12
@sivabur

www.wikihow.com/Execute-HTTP-POST-Requests-in-Android

T
tepexob, 2016-01-13
@tepexob

How to send a POST request using HttpURLConnection?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question