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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T02:22:53+00:00 2026-06-07T02:22:53+00:00

I have a program that search some elements and show these on a GoogleMap.

  • 0

I have a program that search some elements and show these on a GoogleMap.
I want to show a progress dialog before the end of all procedures that set the various geopoint on the map.

Searching I have found this code to show the progress dialog before the end of a method.

    ProgressDialog dialog; 
private class Test extends AsyncTask<Void, Void, Void> { 

    @Override 
    protected void onPreExecute() { 
        dialog = new ProgressDialog(Main.this); 
        dialog.setMessage("Loading...."); 
        dialog.setIndeterminate(true); 
        dialog.setCancelable(true); 
        dialog.show(); 
    } 

    @Override 
    protected Void doInBackground(Void... voids) { 
        try { 
            runOnUiThread(new Runnable() { 
                public void run() { 

                } 
            }); 
            //your code 

    } 

    @Override 
    protected void onPostExecute(Void params) { 
        dialog.dismiss(); 
        //result 

    } 
} 

The class where I must add the async task is something like this:

public class FindItOnMap extends MapActivity{
static String[] foundResults;

@Override
     public void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
         setContentView(R.layout.ricerca_condominio);
         mapView = (MapView)findViewById(R.id.mapView);

         mapController = mapView.getController();

         mapView.setClickable(true);

         mapView.setBuiltInZoomControls(true);

         mapController.setZoom(12);

         myLocationOverlay = new MyLocationOverlay(this, mapView);
         List<Overlay> overlays = mapView.getOverlays();
         overlays.add(myLocationOverlay);
         myLocationOverlay.enableMyLocation();
                 ...........



         ((ImageButton) findViewById(R.id.btSearch)).setOnClickListener(mSearchListenerListener);


}


        OnClickListener mSearchListener = new OnClickListener() {
            public void onClick(View v) {
                    String Location=editorLocation.getText().toString();
                    String name=editorName.getText().toString();
                //static method that updates the lists foundResult
                search(name, location);
                //static method that use the static array foundResult to update the map
                updateMapWithResult();

            }
     };

The methods that requires time before return the solution are invoked when I click on a button

search(name, location);

updateMapWithResult();

The problem is that my class extends yet MapActivity and I cannot use multiple inheritance to extend another class.
How could I do to solve the problem?

  • 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-07T02:22:55+00:00Added an answer on June 7, 2026 at 2:22 am

    If you don’t want to use multiple inheritance, you can define your AsyncTask as an inner class and use an instantiated object of the AsycTask you defined to do your job. Something like this:

    public class FindItOnMap extends MapActivity {
    
    static String[] foundResults;
    private ProgressDialog dialog;
    
     @Override
     public void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
         setContentView(R.layout.ricerca_condominio);
         mapView = (MapView)findViewById(R.id.mapView);
    
         mapController = mapView.getController();
    
         mapView.setClickable(true);
    
         mapView.setBuiltInZoomControls(true);
    
         mapController.setZoom(12);
    
         myLocationOverlay = new MyLocationOverlay(this, mapView);
         List<Overlay> overlays = mapView.getOverlays();
         overlays.add(myLocationOverlay);
         myLocationOverlay.enableMyLocation();
                 ...........
    
    
    
         ((ImageButton) findViewById(R.id.btSearch)).setOnClickListener(mSearchListenerListener);
    
    
         }
    
        OnClickListener mSearchListener = new OnClickListener() {
            public void onClick(View v) {
                    String Location=editorLocation.getText().toString();
                    String name=editorName.getText().toString();
                 //Call the AsyncTask here
                new YourCustomAsyncTask().execute(new String[] {name, location});
    
            }
    
    
        private class YourCustomAsyncTask extends AsyncTask <String, Void, Void> { 
    
            @Override 
            protected void onPreExecute() { 
               dialog = new ProgressDialog(Main.this); 
               dialog.setMessage("Loading...."); 
               dialog.setIndeterminate(true); 
               dialog.setCancelable(true); 
               dialog.show(); //Maybe you should call it in ruinOnUIThread in doInBackGround as suggested from a previous answer
            } 
    
            @Override 
            protected Void doInBackground(String... strings) { 
               try { 
    
                  search(strings[0], string[1]);
    
                  runOnUiThread(new Runnable() { 
                     public void run() { 
                        updateMapWithResult(); //Or call it onPostExecute before progressDialog's dismiss. I believe this method updates the UI so it should run on UI thread
                     } 
                   }); 
    
               } catch(Exception e) {
               }
    
            }
    
        @Override 
        protected void onPostExecute(Void params) { 
            dialog.dismiss(); 
            //result 
    
        } 
    
    
    .....
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to write a program, which search some HTML addresses. I assume that
I have a program that I need to be able to search a file
I have program that runs fast enough. I want to see the number of
I have a program that I want to distribute, without giving the source code
I have a FORTRAN 95 program that needs to make some calls to the
I have program that is used by 4000 users to search a large database
I have a C++ program which does some processing on a char search[500] array.
I have a search program that will be looking at a database from a
I'm writing a program that needs to search a directory and all its sub
I have program that requires Python 3, but I develop Django and it uses

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.