Unwanted duplicated activity


There is a code that sends an int 'a' from the main activity to activity B. It also starts activity B with the fade animations. However, this code creates 2 of the same activity B's and I only need 1 activity B. How can I fix this so that it only makes 1.

new Handler().postDelayed(new Runnable() { public void run() { Handler splash = new Handler(); int a = 1; Intent myIntent = new Intent(MainActivity.this, Differentiate.class); startActivity(new Intent(MainActivity.this, Differentiate.class)); myIntent.putExtra("HEADER", a); overridePendingTransition(R.anim.fade_in_switch_fast,R.anim.fade_out_switch_fast); startActivity(myIntent); finish(); } }, secondsDelayed * 2000);


Hey just remove this line from code:

startActivity(new Intent(MainActivity.this, Differentiate.class));

Rest is fine in your code.


You are starting the second activity twice. Remove the following line from your code and move overridePendingTransition after you use the intent to start the activity:

startActivity(new Intent(MainActivity.this, Differentiate.class));


That's because you are starting Activity B twice!

you should remove this part of your code:

startActivity(new Intent(MainActivity.this, Differentiate.class));


  • Why repeatingAlarm only runs for 1 time only
  • Android - How to create Multiple instances of an Activity?
  • Android activity transition on list view item click
  • how to get values from previous activity
  • How to create fragments in Android studios from existing activities
  • getTag = null pointer
  • Programmatically setting up a vpn on Android
  • Android Store Listview data in SQlite database and retrieve data oncreate of activity in Listview
  • How can I delay onClick action
  • AlarmManager to fire notification at every 24 hours
  • How to Create Forground Service Never Stop when Application is Inactive
  • Android label with self-updating time (hour and minute)
  • how to make two bars in the same fig Matlab
  • How do I make a splash screen load once?
  • How to trigger an alarm only once in Android?
  • How to Delay Execution of Code For X Amount of Time in Android
  • Android Notification Without R.java
  • beforeunload event during window close Vs meteor-auto-reload
  • XNA Number lock affects input
  • How do I periodically change background image?
  • Firebase - retrieve data in Android
  • Android/MongoDB: “NoClassDefFoundError: com.mongodb.DBPortPool”
  • Colorize knockoutjs comment bindings in code editor
  • GUI not updating despite use of validate()
  • Get current day's steps during datapointListener google Fit
  • VerifyInputWhenFocusTarget property has no effect
  • How to Set wallpaper of image with its actual size?
  • Implementing java gui login using multithreading
  • HEAD XMLHttpRequest on Chromium
  • Google Player Game Service Error: Can't build the sample game
  • Android - HorizontalScrollView will not scroll all the way
  • Zend framework 2 : Add different authentication adapter for two different modules
  • setContentView() is not enough to switch between layouts?
  • Android onKey w/ virtual keyboard
  • Regarding starting the threads on a condition
  • PLSQL: Get number of records updated vs inserted when a merge statement is used
  • Detect when Facebook like button is clicked
  • AJAX Html Editor Extender upload image appearing blank
  • Perl system calls when running as another user using sudo
  • Eraser for UIBezierPath
  • SVN: Merging two branches together
  • Hibernate gives error error as “Access to DialectResolutionInfo cannot be null when 'hibernate.
  • Cannot Parse HTML Data Using Android / JSOUP
  • Suggestions to manage Login/Logout transitions
  • JTable with a ScrollPane misbehaving
  • How to CLICK on IE download dialog box i.e.(Open, Save, Save As…)
  • Exception on Android 4.0 `android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode)`
  • Can Visual Studio XAML designer handle font family names with spaces as a resource?
  • unknown Exception android
  • EntityFramework adding new object to nested object collection
  • Checking variable from a different class in C#
  • failed to connect to specific WiFi in android programmatically
  • How can I use threading to 'tick' a timer to be accessed by other threads?