简体   繁体   中英

Android - Web Server Communication

I would like to create a dummy application for connecting my Android phone to my latop and printing out messages through the browser. (Imagine twitter without any of the functionality)

From my thinking I will be using the following:

Client - Android Phone, application Server - Latop, tomcat, servlet, browser

The idea is the application will use Wi-Fi to establish communication between the phone and the laptop, is it required for the android application to specify the use of the phones 3g or Wi-Fi connection in the code. Would sockets be an appropriate choice for establishing a connection? How would I go about defining the server to remain open and active looking for incoming connections from a mobile device with which to output the text communicated via a browser.

I am so vauge but I am assuming I would need to create the Android Application first, open a connection to the IP and Port of the laptop using a socket connection. Using buffer reader and printwriter communicate a users inputed text from the Android application to a servlet on the server side. Within the server a simple out.print to the browser should suffice?

Any thoughts, guidance would be great!

can't you just open an http connection using HttpConnection class? just search for httpclient android. (or open http://developer.android.com/reference/org/apache/http/client/HttpClient.html )

then you can connect to any web server out there ...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM