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();
}
Open PDF in Google Drive with Intent in Android - RRutors
How to get complete address from latitude and longitude?
Fix Error: Use JsonReader.setLenient(true) for Malformed JSON
Fix Play Store Rejection Due to SMS Permission - RRutors
How to find Android Device UDID or unique ID?
How can i comment inside xml file in android studio?
How do I check in SQLite whether a table exists?
How to get screen size (width,height) in Android?
How do I generate random numbers in Dart?
How to avoid multiple button click at same time in android?
What is Android Fragments?
What is Context?
Extract Date and Time from Long Type Variable - RRutors
What is Intent? What is the difference between an implicit intent and an explicit intent?
How To Set Text Color Programmatically Android TextView?
Check List for Generate Signed APK Android
Android Studio project R can't find
How to reduce APK package size?
How to get an image resource by it's name in android?
Invoke-customs are only supported starting with android 0 --min-api 26
Fix Duplicate Files in APK Build.gradle Issue - RRutors
How to check Android version?
How to install/ uninstall apk by command line ADB
How to validate email address in Android with Kotlin?
INSTALL_FAILED_INVALID_APK: Split lib_slice_9_apk was defined multiple times. It is possible that th
How do i load image from drawable folder in Jetpack Compose?
How to copy database from assets folder in android using kotlin
Decompile APK Files: How to Get Source Code - RRutors Guide
How to get a contact image using a phone number in android?
Set Activity to Fullscreen Mode in Android - RRutors
Key Points to remember while develop the Android Application.
How to save activity State in Android?
How to Exit android app on back pressed?
Hide/Disable soft keyboard on Activity launch: Android
How to Get bitmap from drawable: Android
Fix Android Emulator Kill Error When Running Your App
What are the notifications available in android?
FCM Not Receiving Notifications in Android - RRutors
Explain Fragment Life Cycle
What is "shared preferences" in Android ?