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

The Archive Base Latest Questions

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

I have the following code: public class SplashScreenActivity extends Activity { private boolean animated

  • 0

I have the following code:

public class SplashScreenActivity extends Activity {

private boolean animated ;

private Handler handler1;

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState)
    public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);


    if (!isPreviouslyLoggedIn()) {
        setContentView(R.layout.splash);

        final TextView revolution=(TextView) findViewById(R.id.textView1);
        final Button login=(Button) findViewById(R.id.loginButton);
        final Button signUp=(Button) findViewById(R.id.signUpButton);

        login.setOnClickListener(loginListener);
        signUp.setOnClickListener(signUpListener);

        if (!animated) {
            animated = true;
            revolution.setVisibility(View.INVISIBLE);
            login.setVisibility(View.INVISIBLE);
            signUp.setVisibility(View.INVISIBLE);

            ImageView image = (ImageView) findViewById(R.id.image);
            TranslateAnimation slide = new TranslateAnimation(0, 0, 100, 0);   
            slide.setDuration(1000);
            image.startAnimation(slide);

            handler1 = new Handler();

            handler1.postDelayed(new Runnable() {
                @Override
                public void run() {
                    revolution.setVisibility(View.VISIBLE);
                    login.setVisibility(View.VISIBLE);
                    signUp.setVisibility(View.VISIBLE);
                }
            },1200);
        }
    }

    else {
        setContentView(R.layout.home);
        Intent intent = new Intent(getApplicationContext(), PickUpActivity.class);
        startActivity(intent);
    }

}

When the user clicks on one of the buttons, it leads him to a different activity in the same app. However, when the user clicks back from the next activity, the animation is started again. How can I prevent the animation from showing again as i want it to occur only once when user opens the app?

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

    You can use Application class.Declare a boolean var in it and set it “true” before starting second Activity.In your onCreate() of first Activity check this boolean and do animation only it is false(it means that user has not started second activity yet).For example create class with name App in your package:

        public class App extends Application{    
    
        private static boolean animated;
    
        @Override
        public void onCreate() {
            super.onCreate();
            animated = false;
        }
    
        public static boolean getAnimated(){
            return animated;
        }
    
        public static void setAnimated(boolean animated1){
            animated = animated1;
        }
    
    }
    

    Register App in manifest:

    <application
            android:icon= ...
            android:label= ...
            android:name="yourpackage.name.App" >
    

    (I suppose that your package name is :”yourpackage.name”)

    Now change your code like this:

    if (!App.getAnimated()) {
                App.setAnimated(true);
                revolution.setVisibility(View.INVISIBLE);
                login.setVisibility(View.INVISIBLE);
                signUp.setVisibility(View.INVISIBLE);
                ...
    

    Or you can use sharedpreferences and retrieve a boolean from it when you want to start animation.You have to set it’s default value “false” and when user start second Activity,you have to set it “true”.

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

Sidebar

Related Questions

I have the following code: public class Test extends JFrame implements ActionListener{ private static
I have following code: public class readSensorsData extends Activity implements SensorListener { /** Called
I have the following code: Public Class Form1 Private Function Step1_Execute() As Boolean Return
I have the following code: public class TestSynch extends Activity { public static ArrayList<HashMap<String,String>>
I have the following code: public class MyLocationListener implements LocationListener { @Override public void
I have following appDomainManager code public class HostAppDomainManager : AppDomainManager { public override void
I have following code: public class reader extends Activity { WebView mWebView; String mFilename;
I have the following code: public class Events extends ListActivity { //... private static
I have following code public class TEST { public static void main(String arg[]){ try
If I have the following code: public class Foo { public void Bar() {

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.