xiimoss xiimoss - 3 months ago 27
Android Question

Posting values to server in Android using HttpUrlConnection

I'm trying to create a registration page for my application and have got all the values stored in a


I've passed this through to my Class for connection to the server via an ASyncTask however after creating a HttpUrlConnection, i'm not sure how to add these parameters to my URL Connection. Every that i've looked uses NamePairValues but from the research i have performed this has been deprecated.

protected Void doInBackground(String... params) {

String username = params[0];
String firstName = params[1];
String lastName = params[2];
String email = params[3];
String password = params[4];

ConnectionHandler connection = new ConnectionHandler(ctx);

List<Pair<String, String>> args = new ArrayList<>();
args.add(new Pair<>("username", username));
args.add(new Pair<>("first_name", firstName));
args.add(new Pair<>("last_name", lastName));
args.add(new Pair<>("email", email));
args.add(new Pair<>("password", password));

connection.makeConnection(REGISTER_URL, args);
return null;

That's my current doInBackground.

Is there an easier methoid than using

EDIT: I actually ended up using volley which made this some much easier to do.


For anyone finding this later, I ended up using Volley which made the process so much easier.