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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T18:48:05+00:00 2026-06-01T18:48:05+00:00

In my updateGUI() function I update each TextView like so: ((TextView) findViewById(R.id.lbTrackerLat)).setText(String.valueOf(lat)); ((TextView) findViewById(R.id.lbTrackerLong)).setText(String.valueOf(lng));

  • 0

In my updateGUI() function I update each TextView like so:

((TextView) findViewById(R.id.lbTrackerLat)).setText(String.valueOf(lat));
((TextView) findViewById(R.id.lbTrackerLong)).setText(String.valueOf(lng));
((TextView) findViewById(R.id.lbTrackerAlt)).setText(String.valueOf(alt));

When I call updateGUI() from the press of a button with the onclick assigned in the onCreate, the update ALLWAYS works.

I have a locationListener that’s started when the user clicks another button, and on every update event I call updateGUI() there as well, which works until the screen is first rotated, after which the screen is not refreshed for some reason.

While trying to figure out why, I’ve added this code to the updateGUI() function:

TextView t = (TextView) findViewById(R.id.lbTrackerPostLastRefresh);
t.setText(formattedDate);
Log.d("H","EXIT  lbTrackerPostLastRefresh="+t.toString());

After rotation (onCreate is called again), when it’s called from the button click, I get 44c76a78 as the pointer. When the locationListener update function calls findVIewByID, the pointer 44c1b518 is returned!!??

I get that the layout is destroyed and recreated, but why is findViewById returning old pointer values??

Spitballing:
It’s as if the first instance of the View starting with the initial onCreate continues merrily on (along with it’s resources) even after a new View as been instantiated when the device was rotated. Perhaps the LocationListener is doing this because I haven’t stopped it. But stopping and starting it every time the device is rotated seems stupid!

  • 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-01T18:48:06+00:00Added an answer on June 1, 2026 at 6:48 pm

    I am guessing that locationListener is an anonymous inner class of an Activity, which means that it holds a reference to its parent class. So now if this locationListener is not recreated after the onCreate() call, it will reference the old Activity, and a call to findViewById() will return objects hold by that old Activity. Not only will this cause your program to perform incorrectly, but causing memory leaks as well (basically everything created by the original Activity will be retained).

    If the above is not the cause, then I’ll need more information regarding locationListener and how it is used in order to help.

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

Sidebar

Related Questions

I'm trying to write a function to update the multiple select (the second one
Sup Guys, I Have a Function on my frmMain Class wich will update my
I have javascript function that automatically adds input fields together, but adding numbers like
I need to use Drupal 6's hook_user to update a 3rd party API whenever
This is part of my code snippet. I want to pass a callback function
Possible Duplicate: How to update GUI from another thread in C#? I have form
Possible Duplicate: How to update GUI from another thread in C#? I've currently got
I have this what seems like a very tedious task of rescheduling a Timer
How can i make a callback function thread safe. This function will be called
var plugin = { Init: function() { this.UpdateUI(); if (this.Status() == 1) { ...

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.