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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T14:05:10+00:00 2026-06-05T14:05:10+00:00

Hi, I’m a beginner developer of android app. I do this work for a

  • 0

Hi, I’m a beginner developer of android app. I do this work for a University Exam. I read more documentation but I have a problem with show a progress dialog in my activity while the asynktask download a Json String from a server that then I have to put in a listview.
In my UI thread I call the Asynk task, but the thread continue to work and I can’t use the result of the httpGet(that works fine).. I understand this using a Log.i(…)
Why the UI thread dosn’t stop and attend the result?? What I do Wrong?
Please help me.

package my.pack;


import java.util.concurrent.ExecutionException;

import android.app.Activity;
import android.app.ProgressDialog;
import android.os.AsyncTask;
import android.os.Bundle;
import android.util.Log;

public class TestDialogActivity extends Activity 
{


ProgressDialog dialog;
String url = "My URL";
String result= "init";

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    DownloadJsonDataTask task = (DownloadJsonDataTask) new DownloadJsonDataTask(result).
            execute(url);   


    try {
        String ris = task.get();
    } catch (InterruptedException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (ExecutionException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    Log.i("GET",result);



}



public String requestInfoFromServer() {
    String request = null;
    HttpConnection http = HttpConnection.getInstance();
    http.setHttpClient(url);
    request = http.executeRequest();

    return request;
}   

private class DownloadJsonDataTask extends AsyncTask<String, Integer, String> 
{

    String Result;

    protected void onPreExecute()
    {
        dialog = new ProgressDialog(TestDialogActivity.this);
        dialog.setTitle("Download");
        dialog.setMessage("Please wait...");
        dialog.setIndeterminate(true);
        dialog.show();

    }

            public DownloadJsonDataTask(String response) {

                this.Result=response;
            }

    protected String doInBackground(String... urls) {
        String urldisplay = urls[0];

        Log.i("STRING URL:", urldisplay);

        String result = requestInfoFromServer();

        return Result; 

    }


    protected void onPostExecute(String result) {
        this.Result = result;
        dialog.dismiss();
    }
}

}
  • 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-05T14:05:12+00:00Added an answer on June 5, 2026 at 2:05 pm

    ahh I see the problem in the doInBackground(String... urls) function you have declared two different strings with similar names now since variable names are case sensitive it is perfectly legal to have one string named Result and the other named result as R and r are seen as two different characters so thus both have unique names. how ever while this is valid syntax; this is prone to logic errors. And I believe this is where you ran into problems. you did not assign any value to Result only to result by the end of the function call which again is valid syntax and doesn’t point null variable as when you declared Resultit did put in a default value of an empty string. so it will compile and not throw a null pointer error because the variable is not null, even though there is is no string data in it the pointer is still pointing at a valid spot in the memory so as far as the compiler is concerned everything is good, it’s not supposed to check on the contents of the string just pass it on. meanwhile the result variable which you do assign all the data to just before the end of the call gets loaded up with all the data you want. gets completely ignored until the end of the call as there are no further commands dealing with it.and then at the end of the call it gets garbage collected and the data is never passed on as it wasn’t told to pass that variable only the Result one

    make sense?

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I have some data like this: 1 2 3 4 5 9 2 6
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but

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.