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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T04:18:07+00:00 2026-06-18T04:18:07+00:00

I have an application that displays a splash screen then a ‘Showonce’ screen, I

  • 0

I have an application that displays a splash screen then a ‘Showonce’ screen, I have used app prefs and a boolean “user_accept” to decide wether the screen gets displayed or not, trouble no matter if the boolean = true it still shows the page, please see my code for the pages, any help greatly appreciated :).

package com.overclockerz.webtest;

import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.os.Handler;
import android.preference.PreferenceManager;
import android.view.Window;
import android.widget.Toast;



public class SplashScreen extends Activity {

    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        this.requestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.splash_layout);
        final SharedPreferences settings = getSharedPreferences("APP_PREFS",
                MODE_PRIVATE);
        final boolean hasAgreed = settings.getBoolean("user_accepted", false);
        Handler handler = new Handler();

        // run a thread after 2 seconds to start the home screen
        handler.postDelayed(new Runnable() {

            @Override
            public void run() {
                if (hasAgreed == false){
                    Intent intent = new Intent(SplashScreen.this, ShowOnce.class);
                    SplashScreen.this.startActivity(intent);
                    Toast.makeText(getApplicationContext(), "DEBUG: USER HAS NOT ACCEPTED",Toast.LENGTH_LONG).show();
                }else if (hasAgreed == true){
                    Toast.makeText(getApplicationContext(), "DEBUG: USER HAS ACCEPTED",Toast.LENGTH_LONG).show();
                    Intent intent = new Intent(getApplicationContext(), MainActivity.class);
                    startActivity(intent);
                    finish();
                }

                finish();
            }

        }, 2000); // time in milliseconds (1 second = 1000 milliseconds) until the run() method will be called

    }
}



package com.overclockerz.webtest;

import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.widget.Button;
import android.widget.Toast;

public class ShowOnce extends Activity implements OnClickListener {
    Button show_options_dialog, accept_button;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.show_once);
        show_options_dialog = (Button) findViewById(R.id.show_options_dialog);
        accept_button = (Button) findViewById(R.id.accept_button);
        show_options_dialog.setOnClickListener(this);
        accept_button.setOnClickListener(this);


        }

    @Override
    public void onClick(View v) {
        if (v == show_options_dialog){
            Intent intent = new Intent(getApplicationContext(), SettingScreen.class);
            startActivity(intent);
        }
        else if (v == accept_button){
            SharedPreferences settings = getSharedPreferences("APP_PREFS",
                    MODE_PRIVATE);
            SharedPreferences.Editor prefEditor = settings.edit();
            prefEditor.putBoolean("user_accept", true);
            Toast.makeText(getApplicationContext(), "DEBUG: USER CLICKED ACCEPT", Toast.LENGTH_LONG).show();
            prefEditor.commit();
            Intent intent = new Intent(getApplicationContext(), MainActivity.class);
            startActivity(intent);
            finish();
        }

    }

}
  • 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-18T04:18:08+00:00Added an answer on June 18, 2026 at 4:18 am

    you are saving user_accept and checking for user_accepted

    Please use public static final String to avoid such problems:

    public static final String USER_ACCEPTED = "accepted";
    .........
    prefEditor.putBoolean(USER_ACCEPTED , true);
    .........
     settings.getBoolean(USER_ACCEPTED , false);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an android application that displays a toast every hour and then every
I have to design splash screens(images that fit screen while loading) for android application
I have a simple application that starts with a splash screen activity that plays
I have a simple iPhone application that loads very quickly, so the splash screen
I have a mature MFC C++ application that displays on screen and prints using
I have an application that displays the data from 3 xml files (auto generated
I have an application that displays pictures from the internet (showcase for designer work).
I have a portlet. Inside of this portlet I have Flex application that displays
I have an web application that displays employee birthdays for the current month in
I have an application on one domain that displays content from another application from

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.