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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T16:42:15+00:00 2026-05-29T16:42:15+00:00

@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { switch (requestCode) { case

  • 0
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data)
{
    switch (requestCode)
    {
    case REQUEST_VOICE:
        if (resultCode != RESULT_OK) break;
        ArrayList<String> raw = data.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS);
        dialogAdapter.add(raw.get(0));
        dialogAdapter.notifyDataSetChanged(); // Doesn't work?!
        String res = "http://192.168.0.197/xyz.php?v=1";
        res = getFromUrl(res); // Get content from internet
        if (!res.startsWith("{")) res = "Error.";
        else {
            try {
                JSONObject json = new JSONObject(res);
                dialog.set(dialog.lastIndexOf(raw.get(0)), json.getString("in")); // Should update the row that was added before the call of getFromUrl()
                res = json.getString("out");
            } catch (Exception e) {
                res = "Error";
            }
        }
        dialogAdapter.add(res);
        dialogAdapter.notifyDataSetChanged(); // Works?
        break;
    }
    super.onActivityResult(requestCode, resultCode, data);
}

(I’ve shortened the code above.)
The ListView (dialogAdapter is the adapter) will refresh after the function (onActivityResult) is fully executed,
but I want to append a row to it before I call getFromUrl().

Please help.

  • 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-29T16:42:15+00:00Added an answer on May 29, 2026 at 4:42 pm

    The code is working fine as it expected

    The problem which occurs here is you application execution continues till here..

    dialogAdapter.add(raw.get(0));
    dialogAdapter.notifyDataSetChanged(); // Doesn't work?!
    

    actually it works but you are calling another task which hangs the UI thread, here it is:

    res = getFromUrl(res);
    

    It hangs the UI thread to update itself, and after the data has been fetched
    this line executed again.

    dialogAdapter.notifyDataSetChanged(); // Works?
    

    and ListView updated.

    Solutino: Never perform URL request on UI thread. Use AsyncTask

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

Sidebar

Related Questions

Here is the code: @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) {
i found this code: protected override void OnSourceInitialized(EventArgs e) { base.OnSourceInitialized(e); HwndSource hwndSource =
i have the following method in a usercontrol protected override void Render(HtmlTextWriter writer) {
In my code behind I wire up my events like so: protected override void
I have a code: protected override bool ProcessCmdKey(ref Message msg, Keys keyData) { switch
I have this scenario onResume of an activity: @Override protected void onResume() { if
I have the following code... @Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException,
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.picture_choice_activity); Button takePictureButton = (Button)findViewById(R.id.takePictureButton); takePictureButton.setOnClickListener(new OnClickListener()
package { import mx.controls.LinkButton; import flash.text.TextLineMetrics; public class multiLineLinkButton extends LinkButton { override protected
protected override Boolean IsValid(String propertyValue) { return !String.IsNullOrEmpty(propertyValue) && propertyValue.Trim().Length > 0; } This

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.