DroidForums.net is the original Verizon Android Forum! Registered Users do not see these ads. Please Register - It's Free!
Results 1 to 2 of 2

Thread: HTTP POST Help

  1. Junior Droid
    jsg7377's Avatar
    Member #
    13698
    Join Date
    Dec 2009
    Location
    Rochester, NY
    Posts
    18
    Phone
    Motorola Droid
    #1

    Lightbulb HTTP POST Help

    Background:
    I have rigged up a remote start system for my Droid using a WebRelay. I am currently hosting a web server with a small webpage that I access from my Droid. This webpage sends the Lock, Unlock, Trunk, and Start command to the WebRelay in my car via a WWAN connection.

    Objective:

    I am looking to eliminate the hosted web server, and create a simple application that will just send the commands to the WebRelay when the corresponding onscreen button is pressed.

    Problem:
    I am hardware oriented and have no Java experience. I was hoping someone could help me with the syntax and point me in the right direction.

    Accomplishments:
    I have not gotten very far, but I have Eclipse Java EE IDE up and running, with the Android SDK and with my Droid as a debug device.

    Commands :
    I need to only send 4 commands, each to their respective feature (lock, unlock, trunk, start):


    Lock: "htttp://192.168.1.2/state.xml?relay1State=1"
    Unlock: "http://192.168.1.2/state.xml?relay2State=1"
    Trunk: "http://192.168.1.2/state.xml?relay3State=1"
    Start: "http://192.168.1.2/state.xml?relay4State=1"


    Thoughts:
    I am assuming I need to use some sort of HTTP POST method. I did some digging around in the plugins directory of eclipse and noticed there is an apache.commons with HttpClient features. I was hoping this would work to send POST commands in Java.

    Concerns:
    From what I have read there seem to be issues regarding the API (3.x vs. 4.0). This would obviously seem to cause a problem if the eclipse compiler is using a different version. Just something to think about...


    Disclaimer:
    If I am way off base, I'm sorry-- I have never looked at a Java program before yesterday. If this is harder than just creating a simple snippet for each command, I apologize -- please just let me know.

    Thanks in advance!!!
    Last edited by jsg7377; 12-19-2009 at 10:34 AM.
  2. Droid Newbie
    Rizza's Avatar
    Member #
    19060
    Join Date
    Dec 2009
    Posts
    2
    Phone
    Droid
    #2

    Talking

    To send commands to a web address its really rather simple using http post comands, since they are just query string variables, you can do it in two lines..

    //define your URL
    URL myURL = new URL("htttp://192.168.1.2/state.xml?relay1State=1");
    //open a connection to the url
    URLConnection uCon = myURL.openConnection();

    There you go, you sent the commands to the server, thats it. Now if you want to get the response back, you'll need some more code, and i'll be glad to help with that, but hopefully this can get you started. Also dont forget to import the following in order to use the URL and URLConnection objects...

    mport java.net.URL;
    import java.net.URLConnection;

    Again, if you need more help, just email me at briridsdale--DOT--gmail.com (remove the --DOT-- and replace with @. I'll be happy to help walk you through building the app, and the actiivty, and layouts you'll need. Im interested in hearing more about your project.

    Rizza

Links

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

Similar Threads

  1. post #1
    By madpanic in forum Android Applications
    Replies: 7
    Last Post: 12-14-2009, 10:07 PM
  2. Post your applications and what they do
    By arm33n in forum Android General Discussions
    Replies: 1
    Last Post: 12-10-2009, 01:50 AM
  3. Is MSN supported at http://home.mobile.live.com?
    By skottmorris in forum Android General Discussions
    Replies: 2
    Last Post: 12-08-2009, 08:05 AM
  4. Please Post All Questions in ,,,,,,
    By JimMariner in forum Droid FAQ
    Replies: 0
    Last Post: 11-14-2009, 08:36 PM
  5. New Post Icon
    By Zippster in forum Android Tech Support
    Replies: 0
    Last Post: 11-02-2009, 07:37 PM

Search tags for this page

android httppost code
,
android httppost xml
,

http post droid

,
http post url for verizon
,
http post url verizon
,
http post verizon
,
httppost android bug samsung
,

htttp://192.168.1.2

,
htttp:/192.168.1.2
,

verizon http post url

Click on a term to search our site for related topics.

Tags for this Thread

Find us on Google+