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

Universal App / Windows phone, OnBackKeyPressed equivalent

I am trying to get the back button to go back to the previous page instead of closing the app. Until now, I had no luck. Its a universal app but I'm making the windows phone 8.1 first. I have the following code but its not working! protected…
Hunt3R
  • 117
  • 3
  • 13
0
votes
1 answer

back button not in viewPager Works

I've implemented a view pager in my fragment . After pressing the Back button terminates the app instead of the previous page to change . Can someone tell me how I the Back button a page will come back to me . public class Warenkonto extends…
0
votes
4 answers

onBackPressed() override error

i want to implement Appbrain interstitial ad on my live wallpaper settings, i followed steps given on - http://www.appbrain.com/info/sdk-docs/interstitial.html @Override public void onBackPressed() { …
Raj
  • 11
  • 2
0
votes
1 answer

New activity is opened if onBack is pressed

I have a small problem with an activity. There are 3 activities: MainActivity for a login, DataActivity is an activity with 3 tabs, ParameterActivity is an activity to change settings. These are the steps to the problem: The App is started an the…
Selucky
  • 3
  • 3
0
votes
1 answer

Override back button while viewing webview (fragment)

I created a WebView using Fragment; here is my code: public class MyWebView extends Fragment { private WebView webView; @SuppressLint("SetJavaScriptEnabled") @Override public void onActivityCreated(Bundle savedInstanceState) { …
smartmouse
  • 13,912
  • 34
  • 100
  • 166
0
votes
2 answers

Back button on WP8.1

I try to add code to Hardware Back Button on WP8.1 Private Sub onBackPressed(sender As Object, e As BackPressedEventArgs) some code End Sub But when I press Back - my app just closes. onBackPressed event is not happening at all, how can I…
Artur Tychina
  • 105
  • 2
  • 8
0
votes
2 answers

App throws an exception after pressing the back button

I have an app that plays music when opened. But when I stop the music, and use the back button, I get an Exception and the app forcecloses. This is my code: @Override protected void onCreate(Bundle SavedInstanceState) { …
Lukáš Anda
  • 560
  • 1
  • 5
  • 23
0
votes
2 answers

Android activity to android home and again from android home to activity

I have 3 activities in my application. activity1 -->activity 2--activity3 if user press back button in activity3 i am navigating to home page of the mobile using below code Intent startMain = new Intent(Intent.ACTION_MAIN); …
-1
votes
2 answers

How to kill application onBackpress?

Does anyone know how to kill application after onBackpress on Android ? I using this code to close my application. @Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (Integer.parseInt(android.os.Build.VERSION.SDK) <…
Riken
  • 47
  • 8
-1
votes
4 answers

How to send data by click back button?

I'm using two activities, MainActivity & SubActivity. MainActivity.class public class MainActivity extends AppCompatActivity { Button button; @Override protected void onCreate() { ... button.setOnClickListener(new…
hanjiman
  • 465
  • 1
  • 6
  • 17
-1
votes
2 answers

onBackPressed() is not working in Fragment

I want to completely it goes to the home of the phone when i back, but onBackPressed() is not working. My Page is a fragment btw.
Jam
  • 91
  • 12
-1
votes
1 answer

Problem with navigating fragments when i press on back

Have a fragment in which I display the recyclerView list. When I click on a list item in MainActivity I call the method: fun FragmentActivity?.replaceFragment(fragment: Fragment): Boolean { if (this == null) return false try { …
-1
votes
1 answer

Android: onBackPress the fragment reloads

I have a navigation activity with 10 fragments consisting of WebView. Now when I enter/transits from "A" fragment to "B" and later onBackPress it transits back to "A" but it reloads again. I wanted to come back to the same position where "A" was…
-1
votes
1 answer

How to exit an app when Back Button is pressed

This is a small question but I'm finding very hard to solve this. I have multiple activities. For example A B and C. When app is launched A is opened and on click of button will redirect me to activity B and then from B on click of another button…
Bir Nepali
  • 429
  • 1
  • 8
  • 20
-1
votes
2 answers

NullpointerExpection returned when back pressed

I am sending the value from Activity A to Activity B and data is set to the view, it is working fine but when I press back button it is returning the nullpointerexpection in textView.setText() method . I have implemented as follows: Intent i =…
Nabin Dhakal
  • 1,949
  • 3
  • 20
  • 48