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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T15:30:58+00:00 2026-06-14T15:30:58+00:00

I am building an application that will street address from user’s input using GeoCoder

  • 0

I am building an application that will street address from user’s input using GeoCoder. Herewith piece of code I made:

Geocoder gc = new Geocoder(getBaseContext(), Locale.getDefault());

List<Address> addresses = null;
StringBuilder sb = new StringBuilder();
String destination = edittext_destination.getText().toString();

try {
    addresses = gc.getFromLocationName(destination, 10);
} catch (Exception e){
    Toast.makeText(getBaseContext(), "Address not found", Toast.LENGTH_SHORT).show();
}

the code above is working but it takes some time to return the result. While waiting for the result I want to display progress spinner. I know that it should use Thread but I don’t know how to start. I do hope anyone can help.

Thank you

  • 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-14T15:30:59+00:00Added an answer on June 14, 2026 at 3:30 pm

    You could do that with an AsyncTask:

        final String destination = edittext_destination.getText().toString();
        new AsyncTask<String, Void, List<Address>>() {
            private Dialog loadingDialog;
    
            @Override
            protected void onPreExecute() {
                super.onPreExecute();
                loadingDialog = ProgressDialog.show(TestActivity.this, "Please wait", "Loading addresses...");
            }
    
            @Override
            protected List<Address> doInBackground(String... params) {
                String destination = params[0];
                try {
                    Geocoder gc = new Geocoder(getBaseContext(),
                            Locale.getDefault());
                    return gc.getFromLocationName(destination, 10);
                } catch (Exception e) {
                    return null;
                }
            }
    
            @Override
            protected void onPostExecute(List<Address> addresses) {
                loadingDialog.dismiss();
    
                if (addresses == null) {
                    Toast.makeText(getBaseContext(), "Geocoding error",
                            Toast.LENGTH_SHORT).show();
                } else if (addresses.size() == 0) {
                    Toast.makeText(getBaseContext(), "Address not found",
                            Toast.LENGTH_SHORT).show();
                } else {
                    // Do UI stuff with your addresses
                    Toast.makeText(getBaseContext(), "Addresses found: " + addresses.size(), Toast.LENGTH_SHORT).show();
                }
            }
        }.execute(destination);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Background: I'm building a small application that will be run daily, pulling data from
OK, I am building an application that will be using ASIHttpRequest in several places
I am building a Cocoa application that will store customer data. I'm currently using
I am building the application that will load list of news from the website.
I am building the application that will load list of news from the website.
I'm building an application that will have a user base, and I'm at the
I am building a web application that will pull event logs from multiple servers
I'm building a C# application using .NET 3.5 that will require logging in to
I am building an application that will do some object tracking from a video
This is an academical exercise (disclaimer). I'm building an application that will profit from

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.