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 7646617
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T10:15:17+00:00 2026-05-31T10:15:17+00:00

Update based on @Tom solution: SongsManager.java public class SongsManager extends AsyncTask<Void, Void, ArrayList<HashMap<String, String>>>

  • 0

Update based on @Tom solution:

SongsManager.java

public class SongsManager extends AsyncTask<Void, Void, ArrayList<HashMap<String, String>>>    {

          public interface SongsMasterCallback {         
        void showSongList(List<HashMap<String, String>> result);     
    } 

    private SongsMasterCallback  mCallback;      
    public SongsManager (SongsMasterCallback  callback) 
    {         
        mCallback = callback;    
    }   

    // Constructor
    //public SongsManager(){ }


    ArrayList<HashMap<String, String>> songsList = new ArrayList<HashMap<String, String>>();
    @Override
    protected ArrayList<HashMap<String, String>>  doInBackground(Void... params) 
          {
             //populating all the data....
       HashMap<String, String> map = new HashMap<String, String>();
             //.........
             songsList.add(map);
    }

       return songsList;
    }

    @Override
    protected void onPostExecute(ArrayList<HashMap<String, String>> result) {
        // TODO Auto-generated method stub
        //super.onPostExecute(result);
        mCallback.showSongList(result); 
    } 
}

main.java

public class Main extends Activity implements SongsMasterCallback {

public void showSongList(List<HashMap<String, String>> result) 
{
     this.songsList = (ArrayList<HashMap<String, String>>) result;     
     // then do something with the list here 
}

@Override
public void onCreate(Bundle savedInstanceState) {

  new SongsManager(this).execute();
  Log.d("songsSize", "string : "+songsList.size()); //it shows 0 ??? 

}

}

end of update

I am working on a class using AsyncTask and below is what i am getting when i try to execute

the error is on the design time so there is no LogCat

here is the class:

SongManager.java

public class SongsManager extends AsyncTask<Void, Void, ArrayList<HashMap<String, String>>> {


// Constructor
public SongsManager(){ }


@Override
    protected ArrayList<HashMap<String, String>>  doInBackground(Void... params) {
        // TODO Auto-generated method stub

        ArrayList<HashMap<String, String>> songsList = new ArrayList<HashMap<String, String>>();

        Xml_Parser_Custom_Listview parser = new Xml_Parser_Custom_Listview();
        String xml = parser.getXmlFromUrl(URL); // getting XML from URL
        Document doc = parser.getDomElement(xml); // getting DOM element

        NodeList nl = doc.getElementsByTagName(KEY_NAME);
        // looping through all song nodes <song>
        for (int i = 0; i < nl.getLength(); i++) {
            // creating new HashMap
            HashMap<String, String> map = new HashMap<String, String>();
            Element e = (Element) nl.item(i);
            // adding each child node to HashMap key => value
            //adding the rows into to the map...

            // adding HashList to ArrayList
            songsList.add(map);
        }

        return songsList;
    }


}

main.java file

trying to execute the AsyncTask:

public ArrayList<HashMap<String, String>> songsList = new ArrayList<HashMap<String, String>>();
songsList = new SongsManager().execute();

here is the error:

Type mismatch: cannot convert from AsyncTask<Void,Void,ArrayList<HashMap<String,String>>> to ArrayList<HashMap<String,String>>
  • 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-05-31T10:15:19+00:00Added an answer on May 31, 2026 at 10:15 am

    The value returned from SongsManager.execute() is not the results of the computation; it’s the AsyncTask itself. To publish your results, write a method in SongsManager:

    void onPostExecute(ArrayList<HashMap<String,String>> result) {
        songsList = result; // or something similar
        // then update the UI to reflect the results
    }
    

    In this method, songsList is the variable to which you are now trying to assign the return value from new SongsManager.execute(). If this variable is not visible to the SongsManager class (e.g., it’s not a nested class of your main class), then you’ll have to arrange for a call-back:

    public class SongsManager
        extends AsyncTask<Void, Void, List<Map<String,String>>
    {
        public interface SongsMasterCallback {
            void showSongList(List<Map<String, String>> result);
        }
    
        private SongsMasterCallback mCallback;
    
        public SongsMaster(SongsMasterCallback callback) {
            mCallback = callback;
        }
    
        @Override
        protected List<Map<String, String>>  doInBackground(Void... params) {
            // as before
        }
    
        @Override
        protected void onPostExecute(List<Map<String, String>> result) {
            mCallback.showSongList(result);
        }
    }
    

    Then declare your activity to implement SongsManager.SongsManagerCallback and add is method:

    void showSongList(List<Map<String, String>> songList) {
        this.songList = songList;
        // then do something with the list here
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The same as this question but for java Update Based on the comments and
Update: Based on the answers I initially went the route of using IsInstanceOf() which
Update: Based on a couple of the answers I have received, I just want
UPDATE: Based on suggestions here, I've modified my code. To get a handle on
UPDATE: Based on rrenaud's great comment I wanted to clarify that although I'm generating
I'm trying to generate an UPDATE command based on Expression trees (for a batch
I'd like to update a page based upon the results of multiple ajax/json requests.
I'm trying to update one table based on values in another table. What's wrong
I am trying to update a column based on another column in the same
I am using code to update txtunitprice value based on other on click of

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.