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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T09:32:44+00:00 2026-05-19T09:32:44+00:00

I have a strange situation I am seeing. I am reading some info from

  • 0

I have a strange situation I am seeing.

I am reading some info from a database , then bringing up a dialog :
PSEUDO

 val = DBaseManager.readValue(i,POS_ONE);

 if(val == 1)
 {
   Dialog_Test myDialog = new 
   Dialog_Test (myContext,"",new addListener(),DBaseManager);
   myDialog.show();
 }

as you can see I pass into the Dialog the DBaseManager so it can use it also.

then in there I use it like this :

DBaseManager.readValue(k,POS_TWO);

etc.

Now this works 99% of the time, however I have had some crash logs pointing to these lines in the dialog with null pointer exceptions.

To me this is indicating that on some devices my onPause or OnDestory methods are being called in the main activity which closes and nulls DBaseManager. These are 1.6, 2.2 and 2.3 devices.

So the question is why , and how to prevent ? I have added some null pointer checks in to prevent the crashes but it still far from ideal.

UPDATE: On my devices at least when I do a screen rotate the activity is restarted and the dialog disappears – could it be on some the dialogs remains up???

  • 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-19T09:32:45+00:00Added an answer on May 19, 2026 at 9:32 am

    This probably depends on the scope of your Dialog and where in the code you are opening it. The default behavior is for the Activity to go through its lifecycle when the orientation changes unless you explicitly handle orientation changes and override onOrientationChanged. You might want to do something like maintain the state of your dialog at the Activity level (such as adding a boolean isDialogDisplayed as a class variable) and then in onCreate or onResume check that and reopen the dialog.

    As far as the DBaseManager object being cleaned up, I have experienced similar things. Large objects getting cleaned up when you don’t expect them to (there are still pointers to these objects, but they’ve been nulled by the system somehow). I’ve identified these in my applications and just been more careful. Instead of null checking and reloading when null only when it’s possible that your code could have nulled the variable (or using lazy loading), I’d always treat this object as if it were lazy loaded. Add a method that returns this object instead of accessing it directly, and always check for null and reload if it is.

    For both of these two issues, you might want to override all the lifecycle methods of this Activity and log them. Don’t forget to call the lifecycle methods on the base class within your overrides (ie. public void onPause() { super.onPause() ..., etc)!

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

Sidebar

Related Questions

I have a strange situation which I hope someone can shed some light on.
i have a strange situation: I'm using jpa/hibernate to get rows from a mySql
I have faced a very strange situation here. I am accessing database (MDB) through
I have a strange situation with PHP working differently from HTML. I'm not a
I have just encountered a strange situation. I have some basic html: <table bgcolor=#FFFFFF
I have the following strange situation here I need some help with: I am
I am stuck in a very strange situation. I have a database in SQLite
I have a strange situation in regards to xml serialization... If I run MyApp.exe
I have a strange situation here. In my android app, I have a layout
I have a very strange situation. I have a large set of records to

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.