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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T05:47:45+00:00 2026-06-10T05:47:45+00:00

Good day. I have an app that has one main activity which holds 3

  • 0

Good day.

I have an app that has one main activity which holds 3 containers. Every container has a fragment “injected” into it. Upon starting this main activity, it’s forced that first container and fragment are showing, and other two are hidden. On button click, app moves to the second container holding another fragment, and so on.

And this works, it’s going forward to the last container, and backwards to the first container with android back button.

Problem is, if I stop at the second fragment, and I try to go back to the first one, without activating the third one, app crashes with following error:

 java.lang.NullPointerException at
 pl.oke.arshop.activities.ARShopActivity.onBackPressed(ARShopActivity.java:155)
 at android.app.Activity.onKeyUp(Activity.java:1895) at
 android.view.KeyEvent.dispatch(KeyEvent.java:1281) at
 android.app.Activity.dispatchKeyEvent(Activity.java:2075) at
 android.view.ViewRoot.handleFinishedEvent(ViewRoot.java:2463) at
 android.view.ViewRoot.handleMessage(ViewRoot.java:1752) ... etc

where ARShopActivity.java:155 is:

@Override
    public void onBackPressed() {

        if (isVirtualRoomOpened) {
            isVirtualRoomOpened = false;
            showFurnitureFragments();
        } else if (isFurnitureFragmentOpened) {
            isFurnitureFragmentOpened = false;
            showMainFragment();
        }

        super.onBackPressed();
        Log.d("Dab", " " + isVirtualRoomOpened + " "
                + isFurnitureFragmentOpened + " " + isMainFragmentOpened);

    }
}

Any thoughts? Thank you.

  • 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-10T05:47:46+00:00Added an answer on June 10, 2026 at 5:47 am

    Ah, errare humanum est, isVirtualRoomOpened variable is initialized upon creating the last fragment, so when I try to jump back from the second fragment back to the first, argument of first condition is null.

    Setting all of the boolean variables concerning fragments on “false” fixed the problem.

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

Sidebar

Related Questions

Good day, I have created an object that will manage data access. My app
Good day I have a custom TextBox that has a IndicatorTextBox.ui.xml file as well
Good day, I have a ASP.net MVC app that needs to upload files to
Good day to you guys I have an application that has a UITabBarController for
In my app I have SQLite database that has one table with date rows
Good day, I have a class that implements the LoaderCallbacks, and hence have the
Good Day, I have a simple working routine in Perl that swaps two words:
Good Day, I have a Hibernate mapping that looks something like this: public class
Good day, If I have for example the documents which have the following fields
Good day, I have a requirement to create a kind of book app with

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.