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

The Archive Base Latest Questions

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

In Android app i want to return JSONObject from doInBackground() method to onPostExecute() method.

  • 0

In Android app i want to return JSONObject from doInBackground() method to onPostExecute() method.
Here is the code:

private class AddAsyncTask extends AsyncTask<String, Void, String>
     {
         JSONObject jsonObjRecv;
         String result;

    @Override
    protected JSONObject doInBackground(JSONObject... params) {
        AssetObj assetObj = new AssetObj();
        assetObj.setAssetName(txtname.getText().toString());
        assetObj.setMobileNo(txtmobile.getText().toString());
        assetObj.setOwnerId(myApp.getOwnerId());
        assetObj.setStartTime(startTime.getText().toString());
        assetObj.setEndTime(endTime.getText().toString());
        assetObj.setInterval(interval.getText().toString());
        JSONObject jsonObjRecv = SyncService.AddNewAssetRequest(assetObj);
        return jsonObjRecv;
     }
     protected void onPostExecute(JSONObject obj){
                    if(obj != null)
                    {
                        //do something
                    }

I have try this code i got error. Is it possible to return JSONObject from doInBackground() method to onPostExecute() method?

  • 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-13T22:06:13+00:00Added an answer on June 13, 2026 at 10:06 pm

    Edited:

    This could Help you,

    private class AddAsyncTask extends AsyncTask<String, Void, JSONOnject>
     {
         JSONObject jsonObjRecv;
         String result;
    
    @Override
    protected JSONObject doInBackground(String... params) {
        AssetObj assetObj = new AssetObj();
        assetObj.setAssetName(txtname.getText().toString());
        assetObj.setMobileNo(txtmobile.getText().toString());
        assetObj.setOwnerId(myApp.getOwnerId());
        assetObj.setStartTime(startTime.getText().toString());
        assetObj.setEndTime(endTime.getText().toString());
        assetObj.setInterval(interval.getText().toString());
        JSONObject jsonObjRecv = SyncService.AddNewAssetRequest(assetObj);
     }
     protected void onPostExecute(JSONObject obj){
                if(obj != null)
                {
                    //do something
                }
    

    Here is it clearly ,

    private class AddAsyncTask extends AsyncTask<What type of input you need to pass to doInBackground(), Void, What type of return value you need to return to onPostExcute()>
    

    Probably you dont need to change return values and params in the method declaration.

    Just create the following line

    private class AddAsyncTask extends AsyncTask<String, Void, JSONOnject>
    

    the methods will be created automatically according to the params and return types you mentioned in

    private class AddAsyncTask extends AsyncTask<String, Void, JSONOnject>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want my android app to get data from an online database. Here are
I'm building a zip code search page for my Android app so I want
i'm new to android i've created one camera app from scratch in here i
I am creating an android app which pulls in RSS Feeds from here http://spaceflight1.nasa.gov/realdata/sightings/cities/rss/index.cgi?country=United_Kingdom&region=England&city=Manchester
I am trying to send data from android to Django app. I want to
Hi In my android app, I want to get user's input from a EditText
I'm looking to search Google from my Android app and return results. Everything I've
I am developing an Android app and want to share some text by opening
I am developing an android app and I want to know the best way
I am new android app developer i want make app for tablets and phone

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.