Android Programming: Send data via POST to WebView (e.g. to implement an automatic login)
Tip by Progger99 | 2013-05-02 at 11:07
With the following code, it is possible to send data to a WebView using POST with Android:
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); WebView wv = new WebView(this); setContentView(wv); String url = "http://www.example.com/login.php"; String data = "name=Test&password=12345"; wv.postUrl(url, EncodingUtils.getBytes(data, "base64")); }
This code creates a new WebView and opens the website example.com/login.php in it. When opening the page, the data stored in "data" is passed via POST to the web page.
The code can be used, for example, to implement an automatic login by sending the login data via POST to the login page. In th example, we are sending the variables "name" and "password", but, of course, it is also possible to use the code for any other purpose.
About the Author
The author has not added a profile short description yet.
Show Profile
Related Topics
Fonts for Windows, Linux and Mac on the Web
Article | 0 Comments
Android Getting Sound Levels
Open Question | 1 Answer
Android Splash Screen Tutorial
Tutorial | 0 Comments
The Secure Password
Info | 0 Comments
Android Table Layout with columns of equal width
Tutorial | 0 Comments
Android Programming: Receive Responce from HTTP POST Request
Tutorial | 0 Comments
Android Programming: Send data via HTTP POST request
Tutorial | 0 Comments
Important Note
Please note: The contributions published on askingbox.com are contributions of users and should not substitute professional advice. They are not verified by independents and do not necessarily reflect the opinion of askingbox.com. Learn more.
Participate
Ask your own question or write your own article on askingbox.com. That’s how it’s done.