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

  • Home
  • SEARCH
  • 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 8040303
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T03:51:09+00:00 2026-06-05T03:51:09+00:00

In my Android project, I am attempting to send a Map of submitted form

  • 0

In my Android project, I am attempting to send a Map of submitted form data from my main Activity class to a second class which extends asyncTask.

In my main activity, I have the following snippet of code:

Map<String, String> formData = new HashMap<String, String>();
formData.put("name", formName.getText().toString());
formData.put("test", "TESTING");

//formData.get("name"); - this test works

Connection connection = new Connection();
connection.execute(formData);

That sets up my Map of data, successfully tests the first element and sends the form data to my class responsible for working on that data on a separate thread.

But, in my async class, with the following snippet:

public class Connection extends AsyncTask<Map, Void, Void> {
    @Override
    protected Void doInBackground(Map... data) {
        // TODO Auto-generated method stub
        Log.i("TEST", "NEW THREAD FIRING !!!");
        Log.d("DATA", data.get("name"));

        return null;
    }

}

My second log call is attempting to extract the name element of the array map but my “data” object is no recognised as the Map I passed in.

  • 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-05T03:51:11+00:00Added an answer on June 5, 2026 at 3:51 am

    The doInBackground() method is taking in a varargs parameter. Which means that more than one of the type can be passed in at once.

    In this case, there could be more than one map passed in, also in this case, only one IS actually passed in. (You know this because you are initiating the call through AsyncTask‘s execute method). Notice the ... in the method signature? This means that you could pass in multiple Map objects.

    Connection connection = new Connection();
    connection.execute(formData1, formData2, formData3);
    

    You access the values within as you would any array object, that is, with an indexer.

    I believe if you change your code to look like this, it should work:

    @Override
    protected Void doInBackground(Map... data) {
        // TODO Auto-generated method stub
        Log.i("TEST", "NEW THREAD FIRING !!!");
        Map myMap = data[0];
        Log.d("DATA", myMap.get("name"));
    
        return null;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My android project crashes when I try to move from one class to another,
Android 3.2. Attempting to use Switch (http://developer.android.com/reference/android/widget/Switch.html) in my project. Switch.class is not found
In my android project, i want to read a data structure from file. A
I have an Android project I've inherited from another developer. The original code was
I have an Android project for which I use the Eclipse IDE and I
I'm attempting to use OpenCV (on Android) in a project, however I'm struggling to
Launching an android project with google api's from eclipse invokes the device chooser. In
I've been developing a project in phonegap, attempting to build for Android and iOS.
I have a Android project which I'm building in Ant and I'm stuck on
I have a android project which is huge in size with more than 100

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.