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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T01:50:26+00:00 2026-06-11T01:50:26+00:00

I’m working on an Android app. I have an Activity that checks to see

  • 0

I’m working on an Android app. I have an Activity that checks to see if an XML file exists on my device. If it doesn’t exist, I call a routine that does a bunch of stuff, including downloading that file from a URL.

If it does exist, I want to prompt (Yes/No) the user to see if they want to re-download the file, or just skip it.

I started by using a Dialog. The discussions I saw said that Dialogs are only asynchronous, so I switched to using an Activity to prompt for Yes/No.

After further reading, I believe the real answer is that starting an Activity using startActivity() sets off the Activity asynchronously, but using startActivityForResult() sets it off synchronously (blocking). Is this statement correct?

OK, assuming my statement above is correct, I have been looking into how to get back to my original starting point in the code flow, knowing which button (Yes/No) was selected by the user.

All of the examples show me that I need to get my result using this.

protected void onActivityResult(int requestCode, int resultCode,Intent data) {

}

I am struggling with how to put this into my code so that it flows easier. I see plenty of examples that show the pieces of code needed, but I’m not clear on how it all fits together. Does my code structure end up like this:

public class MainScreen extends Activity    {
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    protected void onButtonClick(parameters)    {
        /* Do some work to see if the file exists */
        if (!file.exists()) {
            runComplexRoutine(various_parameters);

        } else {
            Intent myIntent = new Intent(getBaseContext(), PromptingActivity.class);
            myIntent.putExtra("filename", variable_holding_filename);   // Just passing a parameter to use in the title of the caled Activity
            startActivityForResult(myIntent, 1);
                        // Point A
        }
    }


    protected void onActivityResult(int requestCode, int resultCode,Intent data) {
        if (resultsCode == Activity.RESULT_OK)  {
            runComplexRoutine(various_parameters);
        }
        // else, do nothing...
    }

}

My problem with this is that I have to pass lots of various_parameters around. It would be great if I could resume flow at Point A, but that doesn’t seem possible. Am I correct here?

  • 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-11T01:50:28+00:00Added an answer on June 11, 2026 at 1:50 am

    startActivityForResult() is asynchronous. It can feel synchronous to the user since the UI will change and your calling activity will be paused (your onPause() method will be called).

    Your calling activity however is still able to run code; you’ll implement a callback to be called when the activity you started for result is completed (which makes it quite like a dialog).

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

Sidebar

Related Questions

I'm working with an upstream system that sometimes sends me text destined for HTML/XML
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
I have just tried to save a simple *.rtf file with some websites and
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have a French site that I want to parse, but am running into
In my XML file chapters tag has more chapter tag.i need to display chapters
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
I have a reasonable size flat file database of text documents mostly saved in
I'm parsing an XML file, the creators of it stuck in a bunch social

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.