Click here to Skip to main content
15,901,373 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
IDE: Android Studio
Framework: 2.2+

Notes:
I've kept trying to apply the articles I have read online about Android Studio and HTTP Web Requests. I haven't had success yet.

It is just that the depreciated methods are always growing as new content is released, therefore it makes it more challenging to just google it.

Objective:
Could someone write up a sample of an HTTP Post Request to http://www.lipsum.com/feed/html and feed the the requests source to the verbose log?

Restrictions:
I cannot give you the actual objective which I am trying to accomplish, as this is for a college final. Therefore, I can only asked to be pointed the right direction by being previewed to functional examples and online content.

What I Have So Far:
Java
package net.kbhtech.lorumipsum;

import android.support.annotation.NonNull;

import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;

/**
 * Created by Kevin B. Harris on 8/8/2016.
 */


public class HttpRequests {

    private String URL;
    private Map<String, String> Properties;
    private String Source;
    private Method method;

    public enum Method{
        GET, POST
    }

    public HttpRequests(String URL){ // Assumes Get, Returns The Source.
        InitializeComponents();

        // Append Code Below This Line;
    }

    public HttpRequests(String url, Map<String, String> properties, Method method){ // Allows The Dispute Of Method, Adjust URL or Headers As Necessary. Builds
        InitializeComponents();

        // Append Code Below This Line;
        this.Properties = Properties;
        this.URL = url;
        this.method = method;
        this.Properties = properties;
    }

    private void request(){
        if(method == method.GET){
            this.get();
        }else if(method == method.POST) {
            this.post();
        }else{
            throw new NoSuchMethodError();
        }
    }
    
    private void get(){

    }

    private void post(){

    }

    public Map<String, String> getProperties(){
        return this.Properties;
    }

    public String getURL(){
        return this.URL;
    }

    public String getSource(){
        return Source;
    }

    public Method getMethod(){
        return this.method;
    }

    // All Requirements Are Initialized Here, Redefine In Constructor As Neccessary
    private void InitializeComponents(){
        Properties = new HashMap<String, String>();
        URL = "";
    }
}


Thanks;
Kevin B. Harris

What I have tried:

http://www.wikihow.com/Execute-HTTP-POST-Requests-in-Android

http://androidexample.com/How_To_Make_HTTP_POST_Request_To_Server_-_Android_Example/index.php?view=article_discription&aid=64&aaid=89
Posted
Updated 8-Aug-16 0:19am
v2

Sorry, no; this site does not provide code to order, especially for college assignments. You already have links to articles explaining how to do it so it is up to you to do the work. If you have specific problems with code that you write then post the details here and people will try to help you.
 
Share this answer
 
Comments
kbhtech 8-Aug-16 5:48am    
Yes, I have a specific problem. More specifically, I requested a content-less (Not my assignment) task to preview how it was done.

The sources in the articles did not work for me. Even if I can get a "It works" then I would be more satisfied and confident rather than questionable. I have tried to apply them, someone Else's experience may make me more comfortable with them.

Mobile app development moves so fast, that one day something works perfectly then another it is depreciated. Moving towards obsoleted if not obsoleted. Communities like this and questions like mine is what keeps several developers up to date.

I get it, site doesn't provide "code to order" and I understand you work for money not for pleasure. So, move on from these things "wage slave". I didn't ask you, or anyone to do my homework. I simply requested an example.

Although, I did forget and now that I remember (Thanks, by the way) that I will be open to the confirmation that the functionality of these tutorials are still, OK.

By the way Richard, I have been writing software for a long time. I'm really fluent in C# as well as C\C++ and Visual Basic. I excel with the Unix Systems as well as Windows. I grew up dabbing into Visual Basic, Applesoft Basic, Microsoft Visual C#, C++, and C. Your not commenting to a peon, your commenting on someone in a new language.

And, I've got to see a working example of an HTTP Request in android studio.

My assignment is Java. I am just not fluent in it yet. So, what is wrong with me requesting a demo from dummy content so that I can see how that entire assembly functions?

(Again, reiterating: URL is irrelevant, target link can be changed per developer discretion. I picked this because it is dummy content.)
Richard MacCutchan 9-Aug-16 4:14am    
"I get it, site doesn't provide "code to order" and I understand you work for money not for pleasure. So, move on from these things "wage slave"."

No, you obviously do not understand at all how this site works.
kbhtech 15-Aug-16 13:24pm    
Said the person, who did not provide a solution which can be seen directly under this.
Richard MacCutchan 15-Aug-16 15:22pm    
???
kbhtech 8-Aug-16 6:32am    
Also, quoted remarks aren't insults. Hence to why they are quoted: It is simply expression of perception where quotations are the emphasis of personable views therefore nullify-able. I mean, I do this for fun which is more substantial then income.

I respect the moral concentrations at which this individual abides by. I just wanted to point out the things that can be ratified, done away with, personal.

I could have done without the: "I won't point the right direction and I will attempt to have everyone support me in this." So if, moral obligations interfere with an attempt to deliver the understanding that I am trying to achieve through abstraction then please don't comment.

Sincerely,
I hope that I was not perceived as harsh, rude, or crude.
I had viewed your mentioned link's tutorial, all are good to go. I think you are missing something or some point. I am suggesting you to complete this video tutorial, one of the best i have ever seen: https://www.youtube.com/playlist?list=PLshdtb5UWjSppGmM3IdygV6RusjU3KjlZ[^], this will clear most things for you.

If you still find it complex, forget about those and use Retrofit[^] or Volley[^].

I also enclosed a great code examples from Stack Overflow[^] for you. Good Luck!
 
Share this answer
 
Comments
kbhtech 8-Aug-16 6:37am    
Thank You! (Pulling it up now, I will be accepting this as a solution if it works)
ridoy 8-Aug-16 6:39am    
Will be glad if you can do the task, cheers!
kbhtech 8-Aug-16 7:00am    
Is it frequent, that the debugger in Android Studio highlights syntax which may not be invalid therefore actually debugging the code maybe more beneficial in error checking?

If so, that is unlike visual studio. I just keep running into highlighted syntax. I think that I am actually getting detoured by that.
kbhtech 8-Aug-16 8:18am    
It was a gradle, dependency issue.

Without you validating the links that I had given then I would have never been capable of isolating the fault as the sources for mobile application development are always susceptible to obsoleting. The development industry here moves rapidly.

Thank You Much! The Original, before I deleted it and started fresh; Implication of the Libraries was fine the entire time!

(Except, Depreciated)
ridoy 8-Aug-16 11:28am    
Great work, kuddos for the success.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900