Questions tagged [onbackpressed]

onBackPressed is a function called in the Android operating system when the user presses the back key.

onBackPressed is a function called in the Android operating system when the user presses the back key. By default the operating system simply finishes the currently active Android Activity, but it is possible to override the function to do whatever you want, including keeping the current Activity open.

580 questions
-2
votes
1 answer

how do i get calling Activity name if it is a system app ( i.e gallery app )

i have searched a lot but i cant find answer so i thought i should post here. problem my app works on images which are share by gallery application(i.e default gallery app) and its works fine. but i want to override OnBackPress() method to check…
Vishal Patel
  • 554
  • 6
  • 15
-2
votes
1 answer

generic fragment listener for onBackPress()

This question might be duplicated but I need to understand the listener's work principle. Supposing that I have MyActivity() and MyFragment(). I need to make an listener when I'll press back button to run method doStuff() in fragment class. I tryed…
johny
  • 187
  • 1
  • 1
  • 11
-2
votes
1 answer

How to get back on previous RecyclerView list onBackPressed

When I was going through RecyclerView i got a question. I have a RecyclerView list and on clicking on the list item, I can go to another recyclerView list (Just updated data in same RecyclerView). But when I tried to click on back button, My app…
Apurva
  • 148
  • 1
  • 14
-3
votes
7 answers

onBackPressed not going back to previous activity

I've created some activities for my project, but I have some problems when go from one activity to another @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); …
Poeja Network
  • 184
  • 2
  • 17
-3
votes
3 answers

Activity on back pressed handle

Activity launcher I have three activities like Activity A - Activity B - Activity C . Activity launch through intent. When Activity C is launched and I click back button to get activity A with out handle back pressed. How can I get this?
harsh
  • 1
-4
votes
2 answers

how to change behaviour back button in android

My app includes tts and stt. My app works by voice command. So, I want to use the back button. When the user click back button, the app should go to the first step, but it didn't. My code; public class SpeechActivity extends FragmentActivity…
-4
votes
1 answer

onBackPressed() not calling new activity

There is 2 activities in my project. I want to call a new activity when press the back button. I tried both onBackPressed(),onKeyDown() for that. My code is given below. I searched for this in google but nothing worked for me. @Override public…
Remees M Syde
  • 2,564
  • 1
  • 19
  • 42
-5
votes
2 answers

OnBackButton pressed Issue

I have 3 Activities A, B, and C. A is the home activity and B is its child and C is its child. When I go to Activity C and return to A by pressing back button it gets proper navigation. But after this, if I press back button again to exit the app,…
Sayandh
  • 61
  • 1
  • 10
-6
votes
3 answers

Exit application on pressing back with confirmation

I need functionality to exit from the complete application while pressing back button. currently i have a script that ask to press twice to exit application, in that it finish the current activity but does not exits from application old visited…
Deepak
  • 523
  • 4
  • 24
-10
votes
3 answers

Android Disable back button

I want to disable back button in my application. And if not possible, then I want to open MainActivity when click on it. Is there any solution? If yes help me?
1 2 3
38
39