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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T00:11:48+00:00 2026-05-23T00:11:48+00:00

friends, i am using following code inside asyncTask public class AsycLoaderFromDbAndMapInjector extends AsyncTask {

  • 0

friends,

i am using following code inside asyncTask

public class AsycLoaderFromDbAndMapInjector extends AsyncTask
{

    @Override
    protected void onPreExecute() {
        super.onPreExecute();


    }




   @Override
    protected Boolean doInBackground(Void... arg0) {
         Log.d("Asynctask", ""+arg0);  

                boolean show = false;
                if(db == null)
                db = new dbHelper(me);

                ATM results = null;
                try {
                 results = db.getAtmsBySelectedBanks(atm.getSelectedBankList(), selectedCity);
                 if (results != null) {
                        LoopThroughEachATMToDisplayOnMap();
                    }

            return show;

    }


   @Override
    protected void onPostExecute(Boolean result) {
       stopProgress();
    }

private void LoopThroughEachATMToDisplayOnMap()
{

       Drawable drawable = getResources().getDrawable(
                R.drawable.marker);
        itemizedOverlay = new MyItemizedOverlay(drawable, mapView);

        for (int i = 0; i < atm.getAtmList().size(); i++) {

            ATM a = atm.getAtmList().get(i);
            if (a != null) {
                int[] coordinates = getIntCoordinates(a
                        .getCoordinates());
                if (coordinates != null) {
                    GeoPoint point = new GeoPoint(coordinates[0],
                            coordinates[1]);
                    OverlayItem overlayItem = new OverlayItem(
                            point, a.getBankName(), a.getAddress()
                                    + "@@" + a.getPhone() + "@@"
                                    + a.getWebAddress() + "@@"
                                    + a.getCoordinates());
                    itemizedOverlay.addOverlay(overlayItem);
                    System.out
                            .println("coordinates-------------------------"
                                    + i + " "
                                    + coordinates[0]
                                    + ","
                                    + coordinates[1]);
                }

            }

        }


   }


}

now when i press back button this runable populate keeps running in the backend i have used

AsyncTask.cancel() on backbuttonpressed event but still it keeps running any one guide me how to solve this issue?

  • 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-23T00:11:48+00:00Added an answer on May 23, 2026 at 12:11 am

    Try this,

     private ATM results = null;
         @Override
            protected Boolean doInBackground(Void... arg0) {
                 Log.d("Asynctask", ""+arg0);  
    
                        boolean show = false;
                        if(db == null)
                        db = new dbHelper(me);
    
                        ATM results = null;
                        try {
                         results = db.getAtmsBySelectedBanks(atm.getSelectedBankList(), selectedCity);
                         if (results != null) {
                                publishProgress(0);
                          }
    
                    return show;
    
            }
    
    
    
         @Override
                protected void onProgressUpdate(Integer... values) {
                        if (results != null) {
                            LoopThroughEachATMToDisplayOnMap();
                        }
                }
    

    set a flag in LoopThroughEachATMToDisplayOnMap(), to stop the for loop when the back button is pressed.

    That is,

    Detect when the back button is pressed, set the condition variable.

    Inside the loop through method there is a condition variable which will break the for loop.

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

Sidebar

Related Questions

I am trying to get Online Friends by using following code. protected void GetActiveFriends()
I tried the following code: #include <iostream> using std::cout; using std::ostream; class X {
friends, i am using following code to display bitmap on screen and having next
friends, i am trying to check internetconnectivity in android and using following code final
Using the following code to display a list of friends from my twitter profile.
friends, i am using following code to get GPS location it is causing two
friends, i am using following code to display list with radio buttons now i
friends, i am using following code to write Serializable object to external storage. it
I'm using the following code to retrieve the user's friends list and the info
friends, i am using following code to resizeImage private Bitmap resizeImage( final Bitmap image)

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.