Some times we don't want to open activities after pressing back button, examples Splash Screen Activity, Welcome Screen Activity, We don’t need these activities in activity stack. Manifest file <activity Some times we want to close entire application on back press @override or we can do by public void onBackPressed() {
we can remove it from activity stack by below ways
android:noHistory="true"
android:name="com.example.activity"
android:label=""
android:noHistory="true">
</activity>
just place this code in onBackPressed method
public void onBackPressed(){
Intent a = new Intent(Intent.ACTION_MAIN);
a.addCategory(Intent.CATEGORY_HOME);
a.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(a);
}
finish();
}
How to Use Deprecated Handler() in Android - RRutors Guide
What is Intent? What is the difference between an implicit intent and an explicit intent?
Fix Duplicate Files in APK Build.gradle Issue - RRutors
How to convert milli seconds to hours, minutes and seconds in Android?
What is the difference between match_parent and fill_parent?
Fix Play Store Rejection Due to SMS Permission - RRutors
Open PDF in Google Drive with Intent in Android - RRutors
Emulator: emulator: ERROR: Can't find 'Linux version ' string in kernel image file: Andr
What happens next when the device switches between portrait and landscape?
How to install/ uninstall apk by command line ADB
How to copy database from assets folder in android using kotlin
Symmetric vs Asymmetric Encryption in Android Server - RRutors
How to avoid multiple button click at same time in android?
Add Jar/Library Files as Dependency in Android Studio
What is Application?
What are Android Versions available?
How to Get bitmap from drawable: Android
How to stop EditText focus at Activity startup in Android?
How to validate email address in Android with Kotlin?
How to save activity State in Android?
What is Android?
Fix Error: Use JsonReader.setLenient(true) for Malformed JSON
How to get screen size (width,height) in Android?
How to find Android Device UDID or unique ID?
Key Points to remember while develop the Android Application.
Check List for Generate Signed APK Android
Invoke-customs are only supported starting with android 0 --min-api 26
Extract Date and Time from Long Type Variable - RRutors
Fix Android Emulator Kill Error When Running Your App
How to check Android version?
FCM Not Receiving Notifications in Android - RRutors
How To Set Text Color Programmatically Android TextView?
How to get an image resource by it's name in android?
How to start a new activity on button click
What is the Different Between val and var in Kotlin?
ERR_ACCESS_DENIED in Android Webview with sdk 30
What is Android Fragments?
Explain Fragment Life Cycle
Fix Behavior Subclass BottomSheetBehavior Exception - RRutors
Decompile APK Files: How to Get Source Code - RRutors Guide