Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8991615
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T22:46:12+00:00 2026-06-15T22:46:12+00:00

Seemingly simple question, but no obvious answer found online. At this link, there is

  • 0

Seemingly simple question, but no obvious answer found online.

At this link, there is a tutorial on posting simple name value pairs to a file from within an android app. http://www.androidsnippets.com/executing-a-http-post-request-with-httpclient

What I want to do is post ‘something’ which on the receiving end (a php script) can be accessed as an array.

In PHP I want to receive:

$_POST[‘array’]=array(“key”=>”value”,”key2″=>”value2″);

Being relatively new to android development, perhaps someone could elaborate on creating a similar thing in Java, and then how one cant send it – setEntity seems to only take namevaluepairs…

Many Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T22:46:13+00:00Added an answer on June 15, 2026 at 10:46 pm

    You should use a JSON Wrapper both in Android App and your PHP server.

    In PHP you should use json_decode(), like: $thingFromPost = json_decode($data).

    In Java, there are many ways to create a JSONArray. A basic example would be:

    List<String> list = new ArrayList<String>();
    list.add("foo");
    list.add("bar");
    JSONArray jsonArray = new JSONArray(list);
    

    And after that, you just send your array with a HttpPost to your server.

    StringEntity stringEntity = new StringEntity(jsonArray.toString());
    stringEntity.setContentEncoding(new BasicHeader(HTTP.CONTENT_ENCODING, "UTF-8"));
    stringEntity.setContentType(new BasicHeader(HTTP.CONTENT_TYPE, "application/json"));
    
    HttpPost post = new HttpPost(url);          
    post.setEntity(stringEntity);
    post.setHeader(new BasicHeader(HTTP.CONTENT_TYPE, "application/json"));
    

    If you need a detailed tutorial how to make requests using JSON in Android, follow this link.

    Hope it helps!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I looked and looked but couldn't find an answer to this seemingly simple question
I am thinking there is a simple answer to my seemingly simple question but
I searched and searched for an answer for this seemingly simple question in Commerce
This seems like a noob question, but the simple answer is eluding me. I
So, this is a seemingly simple question, but I'm apparently very very dull. I
This is a simple question, and a seemingly simple task but I can't find
My question is seemingly simple but has been pretty elusive. I want one value
A simple question: Why does this the first code work but the seemingly identical
I've searched hi and low for an answer to this seemingly simple question, however
I have a seemingly simple question, but can't find the answer. I have a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.