Override the onBackPressed method and do nothing if you meant to handle the back button on the device.
@Override
public void onBackPressed() {
if (shouldAllowBack()) {
super.onBackPressed();
} else {
doSomething();
}
}
More Related Contents:
- How to POST raw whole JSON in the body of a Retrofit request?
- How to customize a Spinner in Android
- How to programmatically move, copy and delete files and directories on SD?
- How to import existing Android project into Eclipse?
- How to remove application from app listings on Android Developer Console
- Force overflow menu in ActionBarSherlock
- Error – Android resource linking failed (AAPT2 27.0.3 Daemon #0)
- “realm migration needed”, exception in android while retrieving values from realm db
- Android – Controlling a task with Timer and TimerTask?
- What is the difference between Activity and Context?
- Is it possible to evenly distribute buttons across the width of a LinearLayout
- Android ExpandableListView – Looking for a tutorial [closed]
- Android path to asset txt file
- Editing Functionality of Host Card Emulation in Android
- restrict edittext to single line
- No Network Security Config specified, using platform default – Android Log
- Change Media volume in Android?
- How to update Notification with RemoteViews?
- Check if a VPN connection is active in Android?
- Getting all the total and available space on Android
- How to hide the share action (which use most) icon near the share action provider?
- How to filter the data in realm adapter?
- get the last picture taken by user
- CardView inside RecyclerView has extra margins
- android: How can I implement first time tutorial like Go Launcher in my app?
- Firebase Android onAuthStateChanged called twice
- Start AlarmManager if device is rebooted
- What difference between static and non static viewholder in RecyclerView Adapter?
- android – how to prevent webview to load when no internet connection
- Why Bitmap to Base64 String showing black background on webview in android?