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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T00:30:24+00:00 2026-06-01T00:30:24+00:00

Currently, my app has a mapview that creates a new MyLocationOverlay in the onCreate

  • 0

Currently, my app has a mapview that creates a new MyLocationOverlay in the onCreate function.

locationOverlay = new MyLocationOverlay(this, map);
locationOverlay.runOnFirstFix(centerAroundFix);
map.getOverlays().add(locationOverlay);

I’m trying to create a button that does this optionally, much like google maps. This is what I have so far.

ImageButton locButton = (ImageButton)findViewById(R.id.googlemaps_select_location);

locButton.setOnClickListener(new OnClickListener() {
    public void onClick(View v) {
        locationOverlay = new MyLocationOverlay(ctx, map);
        locationOverlay.runOnFirstFix(centerAroundFix);
        map.getOverlays().add(locationOverlay);
    }
});

The only thing I had to change was the ‘this’ to ‘ctx’. I set ctx = this in the onCreate() function. I’ve also tried using getApplicationContext() instead of ctx

Using the debugger, I break on the onClick() function and can step through it. After hitting run, I telnet to the emulator and use the geo fix command to issue a fix to the emulator. Unfortunately, centerAroundFix() is never called. Not sure what I’m doing wrong, 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-01T00:30:25+00:00Added an answer on June 1, 2026 at 12:30 am

    I resolved this by moving
    locationOverlay = new MyLocationOverlay(ctx, map)
    to the onCreate() function.

    Perhaps locationOverlay get garbage collected if it’s inside the onClick() function?

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

Sidebar

Related Questions

The app I'm currently building has the requirement that the app has to prevent
I'm currently making an iPhone app that has PDF viewing a crucial part of
I'm building an app that currently has 3 ViewControllers. One of them is used
I currently have an app that has a UIScrollView with paging as the primary
I'm currently coding an app that has hotkey functionality, I've done some reading and
I currently have an app (in Silverlight), using mv-vm, that has an interface to
Currently, my MVC 3 app has a dependency on a static class that is
I am currently developing an app that has a TabBarController and each of the
I am currently developing an app that has to be able to share documents
I'm currently making an android map based app. The purpose of this app is

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.