How to send html form using to https resource in Android? - android

I only want to send an html form by post method to a https resource from an Android activity.
I have (only for development and testing) an Lighttpd server with it own certificate to make handshaking, so there MUST happen authentication at least from server (client authentication is optional but desirable).
I have seen, lots of forums with different ways to make it, but I am a little confused, I do not know which could be the correct way to make it.
Please show me a chunk of code.
Thank you very very much.

Try out this tutorial, it shows GET, POST and Multipart POST request on the android platform
http://www.softwarepassion.com/android-series-get-post-and-multipart-post-requests/

I wrote some code to submit an HTML form to a server over https, which can be found in this answer. The version in the answer uses an HttpsUrlConnection, and the version in the question uses HttpClient. I could never quite get the right result from the server with the HttpClient version, but either approach should work in theory.

Related

How to set programmatically cookies using Crosswalk XWalkView?

I need to make a webview application that POST a username and password and then display the webpage logged-in. I must use cookies but i chouldn't find how to do it, tried the traditional ways but nothing.
Has anyone had any experience with xWalkView and how to get/put cookies ?
(I am using xWalkView since the traditional webview on android 4.2.2 can't load HTML5 webpages)
I had the same problem but I did not find the exact answer. Instead, I found a kind of a work around.
As I am using a servlet container, I append a ";jsessionid=" to every request I make to the server.
The other thing than can actually work for you regardless of what backend you use is to make a request to your web server so that it returns a response with a cookie.
For example if you want to add a name=test you could make some xhr request to some url and the response must have the cookie name=test in it. This technique also work for me for session tracking in my java app.
Good luck

Socket.io and node.js example in android

I am new to socket programming i have to use socket.io and node.js to connect with my server host in android so can anyone please just describe me the programming example of how to connect to server in android. And if possible please give some help regarding node.js and socket.io. As i have searched everywhere on google but not able to find out the proper example.
Thanks
You can just have your web service be REST base.
Your Android application can just talk to your web server via REST and receive data json or xml whatever you fancy.
So with node.js you should set up routes.
An example would of a route would be
www.example.com/users via GET post would return a list of users either in JSON/XML
For your android application you need a library, I believe there's a built in one already, to make request for certain routes such as www.example.com/users via GET method and write the logic to expect JSON or XML and parse that.
I just googled this:
Android: https://github.com/koush/ion
As for node.js you just have to build route...
I think is would be better:
websocket api to replace rest api?
It actually invalidate my answers sorry, REST and websocket api are different.
I have no clue what problem exactly you have. But you should break your problems down to small part. And google and search for answer for each smaller part which would make your life easier to google.
Get your webservice up first so that your android software can consume stuff, build a prototype and then build a prototype of android app that consume data from that webservice.

Set up a server and get feed from it in android

This may not be the type of question I am supposed to ask here but I don't have anywhere else to go. I want to make an android application which gets feed from a web-server and displays in the application. It will be kind of a newspaper app. I have done my share of work: I know android application developemnt: have made some apps. Also, I have an idea of UI: a listview with the feeds and then on selecting an element I will open another activity with the complete feed. What I wanted to know is:
How to set-up a server for this?
How to request?
Can I set-up a free server?
I dont want to use GCM as I don't think it allows sending pictures. Plus it allows small data to be sent. Also, I have no knowledge about the 3rd party server I may need to create for this.
I would want to post both text and photos (combined makes a post, total of around 10 posts) from the server. Please dont close as not a question. Any link, tutorial will be highly appreciated. For server side coding, I know php, .net. I have never coded in java for a server, but I can learn it.
Please follow following steps to get your project done.
Set up any php or Java or .Net Server (If you are aware of any of these web technologies)
After you set up server you need to make web service which will work as mediator to transfer data between your server and mobile.
Webservice response will be either in JSON or XML
Generate response according to your need and parse them on android side.
Display in listview :) :)
You can use JBOSS for your server, and do a Java Server with Webservices.
In your webservices you'll have a service that get all the feeds, and maybe another that request the complete feed...
Your "language" between the Android app and the Server, you can use XML with SOAP (ksoap2 for Android), or you can try JSON (I never used, but I will 'cause we goona need use in my service).
You can try find another free server side, but I think the SOAP is important in most of the servers to "talk" with your app.
I hope helped you.
[]s
Bertan

Sending an OPTIONS request in Android is not working

I am trying to send an OPTIONS request from my android application to my Windows 2008 Server webservice (which is a .net webservice). I am using SSL, and am having difficulty getting this to work. I really need to know exactly what my headers should look like. I know I don't send the body, I just need to know what to send. I really need an example not a link to someone just talking about some things.
I found the answer. It was working. I just wasnt looking in the right place for my response. I was looking at the final response that I get from my Soapbuilder class, and I am stripping out the headers before returning. I is actually giving the right options headers back.

How to make a POST request from inside a Restlet

I'm current using Restlet to interface with an Android app.
I want the Restlet on the server to then trigger a C2DM push message when it gets a certain POST from an Android app - it's basically just a simple HTTP POST to Google's servers with some extra values in it.
I imagine there must be some way of using the in built connector, or otherwise, anyone have any ideas? Can't seem to find anything about it on the net, an unusual request perhaps.
Edit: Probably should have expanded on this to begin with, the reason why I ask is that I'm trying to use Apache httpClient inside the restlet but I'm not able to to get it to work. If that is what you're supposed to do, then it's probably a different question altogether.
Use Java's native HttpURLConnection object: http://download.oracle.com/javase/7/docs/api/java/net/HttpURLConnection.html
Follow the implementation guidelines provided by Google: http://code.google.com/android/c2dm/#push
So what I was doing is the right way to do it after all, I've got Apache HttpClient set up and working in a seperate thread to do the push. For some reason it fails due to a peer exception (which is the exception I was getting initially), but I've got around that by automatically trusting the SSL certificate. Why that was happening with the C2DM address I really have no idea.

Categories

Resources