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
0
votes
1 answer

is it posible to add two backpress event in same activity in android

I am working on simple project and at some point am stuck.in my activity am using dialog box. I want to add backpressed() event on dialog box and whole activity.but when I add 2 same method it shows me error.
0
votes
1 answer

Navigation drawer with fragment and on back pressed

I have a navigation drawer with only one activity and several fragments. My main fragment is really heavy to load so I try to keep it in memory because if I don't do it the drawer will be laggy when I use it. To do so I have a layout like this…
0
votes
3 answers

onBackPressed Is Not Working

The onBackPressed method is not called when the app is running so I can't properly quit the app I added a log message but I don't see it called anywhere what could be the problem MainActivity @Override public void onBackPressed() { Log.v(TAG,…
Jacques Krause
  • 5,523
  • 9
  • 27
  • 43
0
votes
2 answers

Exit to the menu with back button

I am new in Android. I have "Menu" activity in which I have ListView with 3 items. When I click on the first item it is opening new Activity ("Play" activity). In that activity I have a button which calls another activity "Result". I am trying to…
user3079114
  • 69
  • 1
  • 12
0
votes
2 answers

Error calling a new class using the onBackPressed method

I was trying to use the onBackPressed() method to open an activity that I need and close the existing one but the application close unexpectedly; I put a try catch if I can see the error but the variable "e" comes null, the only thing that show me…
jugger
  • 1
  • 6
0
votes
2 answers

How get back to previous activity by onBackPressed() and use new theme?

i have an app with 3 activities:main,second,preferences. i can call preferences from main and second one.for preferences i used PreferenceActivity. i my preferences i want to change theme. but the problem is that the theme changed only when activity…
0
votes
2 answers

Android MediaPlayer stops on backpressed

I'm developing a radio stream app.I use android - mediaplayer class which plays radiostream. I m trying to run app in two devices . When I pressed back button in Samsung galaxy S3 mini(4.2.2) radio stream continues to playing. And I controls media…
0
votes
0 answers

Backpress sound played twice when overriding onBackPressed()

I'm working on a music player for android. In it I have an activity which contains ListView that displays songs/artists/albums etc. I keep track of the lists the user views (For example all album --> artist x --> album y) In order to provide a way…
Dor Shinar
  • 1,474
  • 2
  • 11
  • 17
0
votes
2 answers

Manage ActionBar Title onBackPressed with ViewPager

let me define my problem first: i have a ViewPager with ActionBar, each page of view pager is a fargment and each page itself got its own buttons to replace current fragment with another one. for example: we first launch the application and…
0
votes
3 answers

How to end AsyncTask onBackPress()

how to stop asynctask on android backpress i want to stop this activity so that when it goes back to previous activity this activity is completely closed this activity does its work in background , as it is supposed to do, my problem is when we…
1234567
  • 2,226
  • 4
  • 24
  • 69
0
votes
0 answers

Android: nested fragment commit error while activity is being destroyed via onBackPressed

The app crashes only when I start this fragment (for the first time) and press the back button at the same time. I have not overrided onBackPressed() in my activity. Code: Fragment Class public class Fragment_View extends Fragment…
0
votes
1 answer

Android clear all webView and activity history whatsoever

I have MAIN Activity and WEB activity with webView. MAIN always performs some processing and redirects automatically to WEB. When on WEB I enter Preferences, make preference changes and when I press Back I return to WEB. However, in preferences I…
ofermc
  • 287
  • 3
  • 10
0
votes
2 answers

Using onbackpressed on homepage to exit app, setting homepage variable

I'm developing an Android Webview app. I would like to use onbackpressed to go to the previous page but also to exit the app. How it should work: Pressing back-button on homepage: I want to show a message "Press once again to exit." Pressing…
Stan
  • 937
  • 5
  • 15
  • 33
0
votes
2 answers

Using onbackpressed on homepage to exit app, in other case go to previous page

I'm developing an Android Webview app at the moment. I'm using the following code to exit my app. The problem is that by using this code, I can't return to the previous page anymore so it's not yet what I had in mind. Goal: I'd like to show the…
Stan
  • 937
  • 5
  • 15
  • 33
0
votes
1 answer

How can is send textView Value From One active to other in android?

I am building an android application Where on click of an Image-view the OnBackPressed Function is called. Here is code - ImageView imgv = (ImageView) mCustomView.findViewById(R.id.back); imgv.setOnClickListener(new OnClickListener() { …
Test123
  • 368
  • 1
  • 7
  • 26