back

Close app when hitting back button on android

爱⌒轻易说出口 提交于 2019-12-21 09:35:03
问题 So my login Activity is the first screen you see. When you hit the back button, it exits the app, good. So I open up the app again. After logging in, I am now in my main Activity. How do I make it so when I hit the back button now, it exits the app rather than going back to the login Activity? 回答1: When you push the new activity, call finish() on the previous, otherwise it will remain on the stack, therefore appearing when you hit back and pop the current activity. Hope that helps. 回答2: try

UINavigationBar: intercept back button and back swipe gesture

筅森魡賤 提交于 2019-12-21 05:46:16
问题 I have a UINavigationBar that intercepts the back button tap that alerts the user if there are unsave changes. This is based on the solution presented in UINavigationController and UINavigationBarDelegate.ShouldPopItem() with MonoTouch using the UINavigationBarDelegate protocol and implementing - (BOOL)navigationBar:(UINavigationBar *)navigationBar shouldPopItem:(UINavigationItem *)item; Now, iOS7 has introduced the swipe-to-go-back gesture, and I'd like to intercept that as well, but can't

Modify iframe.src without entry to history object

故事扮演 提交于 2019-12-21 05:00:07
问题 I have an iframe in my web page. I modify the src property via javascript like so: document.getElementById('myiframe').src = 'http://vimeo.com/videoid1'; document.getElementById('myiframe').src = 'http://vimeo.com/videoid2'; document.getElementById('myiframe').src = 'http://vimeo.com/videoid3'; However, everytime I do this, it's logged into the browser's history. So everytime I press back in the browser window, the iframe content goes from videoid3 to videoid2 to videoid1. If I press back

Is there an onBackPressed() alternative for a service?

大兔子大兔子 提交于 2019-12-21 03:57:21
问题 I know that services cannot implement Back key press and I understand the rationale. But there is an app called SideBar (on Play Store) that reacts to back key presses. It is a service that adds a view as system overlay and removes the view when the back key is pressed. Can anybody explain how this is done? Here is another app that does it well. I have scoured the web, but have not found a solution to this problem. Any ideas? 回答1: It is probably done using system alert windows - so the

Problem with back button in my app [closed]

三世轮回 提交于 2019-12-20 07:48:26
问题 It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 8 years ago . I want to clear shared preference values when my mobile is switched off? 回答1: How can you clear SharedPreference when the device is switched off . You can clear it when the device starts thru BraodcastReceiver .

Pressing back prefills inputs with value from right before submit

烈酒焚心 提交于 2019-12-19 10:31:31
问题 With the following htlm: <html> <body> <form action="#"> <p><input type="text"></input></p> </form> </body> </html> On load the input has an empty value. Change it to "1" and enter (submit) The page will show a "1" Pressing back will prefill the page with the entered "1" instead of the initial state (empty) My real world application is an asp.net page where the top of the page contains search inputs and the bottom the results. When pressing back the fields are prefilled with values that don't

Leaving android app with back button

痴心易碎 提交于 2019-12-18 11:57:14
问题 I want the users of my android app to leave my app when they press back at a certain activity. Can this be done? 回答1: You can try something like this (shows a dialog to confirm exit): @Override public void onBackPressed() { new AlertDialog.Builder(this).setIcon(android.R.drawable.ic_dialog_alert).setTitle("Exit") .setMessage("Are you sure you want to exit?") .setPositiveButton("Yes", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) {

Startup JavaScript code is not executed when using the Firefox “Back” button

混江龙づ霸主 提交于 2019-12-18 04:23:11
问题 This website has a fancy effect: when a navigation link is clicked, the content fades out and when the new page (on a different URL) loads, its contents fade in. What's interesting is, after users click on the "Back" button of their browsers, they go back to the previous page and the content still fades in . In other words, the previous page doesn't stay at the faded-out state, which is what was last seen. According to this comment, a page should be staying at its last seen state. I tried

Android - How to animate an activity transition when the default back button is pressed

心不动则不痛 提交于 2019-12-17 18:22:42
问题 In my activity, I have a button with the following click listener that is working great: final ImageButton startOverButton = (ImageButton) findViewById(R.id.start_over_button); startOverButton.setOnClickListener(new View.OnClickListener(){ @Override public void onClick(final View v) { finish();//go back to the previous Activity overridePendingTransition(R.anim.comming_in, R.anim.comming_out); } }); It animates the return to the previous activity the way I want. However, when the user presses

React Native - Device back button handling

拟墨画扇 提交于 2019-12-17 16:06:47
问题 I want to check if there are more than one screens are on stack when device back button is hit. If yes, I want to show previous screen and if no, I want to exit app. I have checked number of examples but those use BackAndroid and Navigator. But both of them are deprecated. BackHandler is replacement for BackAndroid. And I can show previous screen by using props.navigation.goBack(null). But I am unable to find code for finding screen count in stack. I don't want to use deprecated Navigator!