Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 13 of 13

Thread: android app connected to a server

  1. #1
    Junior Member
    Join Date
    Aug 2014
    Posts
    29
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default android app connected to a server

    Hi all.
    I am currently working on an android app that needs to connect to a server and get some data.
    What is the protocol used for such communication? I have been testing it on my local machine, so i created a java socket server. But when i tried to upload it on the web in order to test it, i realised that it is not so easy/cheap to do it, so i turned to servlet. Curently i am at the prosess of changing my socket server to a servlet, but i would hate doing it twice, i thought to ask first if there is a better alternative.

    Thanks, ilias


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: android app connected to a server

    You might be able to test the client/server code on a LAN via wifi. Start the server, get its IP address and see if the client can connect to it. For example, there is a free app on Play Store (WiFi file transfer) that has a server that runs on one android tablet that a browser on another tablet can connect to for copying files from the server.
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Junior Member
    Join Date
    Aug 2014
    Posts
    29
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default Re: android app connected to a server

    Either i didnt explain properly, or you didnt get it right... or i didnt understand your answer.

    My android app needs to connect to a server, sent some data and get a reply. Actually it is an apointment system. I need to ask for an apointment, lets say Friday @ 11:00 and the server would say apointment set, or if the slot is taken to ask from the user for an other slot.

    My question is what technology to use for this communication

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: android app connected to a server

    A standard way to connect to a server is with HTTP. What protocols does your server support?
    If you don't understand my answer, don't ignore it, ask a question.

  5. #5
    Junior Member
    Join Date
    Aug 2014
    Posts
    29
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default Re: android app connected to a server

    Its my server, I am coding the server as well.
    I am planning to do it in Java, cos i am more familiar with it than other languages.

  6. #6
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: android app connected to a server

    Is the server going to run in Android on a tablet/phone?
    If you don't understand my answer, don't ignore it, ask a question.

  7. #7
    Junior Member
    Join Date
    Aug 2014
    Posts
    29
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default Re: android app connected to a server

    No, it will be a pc.

  8. #8
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: android app connected to a server

    There are several packages available from Apache that could be useful. Or look at the Java SE classes.
    The HTTP server I wrote long ago as a learning exercise used Sockets. That meant I had to write code to handle many things that the current classes probably provide.
    If you don't understand my answer, don't ignore it, ask a question.

  9. #9
    Junior Member
    Join Date
    Aug 2014
    Posts
    29
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default Re: android app connected to a server

    So an http server using doPost would be an acceptable solution for an android client connected to a server.

    I was thinking my architecture to be something like that,
    on a trigger the client (android) will sent a string as a command to the server (for example "apointment=Doc&time=11:00&date=11/11/2014")
    This will be read from the server and depending on the value of apointment to execute a different group of commands, returning the apropirate data to the client.

    How does that look like?

  10. #10
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: android app connected to a server

    I think HTTP POST would be fine.
    If you don't understand my answer, don't ignore it, ask a question.

  11. #11
    Junior Member
    Join Date
    Aug 2014
    Posts
    29
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default Re: android app connected to a server

    Sorry, i presed send with out really looking.

    Thanks for the help. I will go on and use http and see how it goes.
    Last edited by skarosg3; September 16th, 2014 at 01:06 PM. Reason: duplicated post

  12. #12
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: android app connected to a server

    I think HTTP POST would be fine.

    That looks like an exact repeat of the previous post.
    If you don't understand my answer, don't ignore it, ask a question.

  13. The Following User Says Thank You to Norm For This Useful Post:

    skarosg3 (September 16th, 2014)

  14. #13
    Junior Member
    Join Date
    Sep 2014
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: android app connected to a server

    HTTP POST should do the job, but you may to use to use tomcat as well depending on the complexity of your project

Similar Threads

  1. Creating an android app.
    By absineo in forum Android Development
    Replies: 3
    Last Post: May 13th, 2014, 05:02 PM
  2. QA for Android app
    By deependeroracle in forum Android Development
    Replies: 1
    Last Post: February 28th, 2014, 10:23 AM
  3. Android Camera app
    By Yoyo_Guru in forum Android Development
    Replies: 1
    Last Post: July 26th, 2012, 01:47 PM
  4. Hello World Android App
    By TP-Oreilly in forum Android Development
    Replies: 6
    Last Post: January 22nd, 2012, 08:01 PM
  5. help with keeping client connected to server
    By frozen java in forum What's Wrong With My Code?
    Replies: 0
    Last Post: November 19th, 2011, 02:29 PM