back

onBackPressed() not working

时间秒杀一切 提交于 2019-12-01 01:20:43
I'm trying to close my app on a back button click. From the main screen, the back button takes you to a credits screen. From that credits screen, I want to close the app with the back button. Unfortunately, the onBackPressed() method I'm calling doesn't seem to be executed at all. I'm not sure how to proceed. package app.jonward.boss; import android.app.Activity; public class Credits extends Activity{ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.credits); //Doing stuff } @Override public void onBackPressed() { finish();

Jquery when back button is pressed

给你一囗甜甜゛ 提交于 2019-11-30 17:27:53
I have a click that changes things on the page when you click it. I was wondering if there was a way to trigger an effect when you press the back button on the browser You can sort of do it using the popstate event: window.onpopstate = function() { alert("pop!"); } or in jQuery : $(window).on('popstate', function(event) { alert("pop"); }); However this will also trigger when navigating forward, not only backward. Disable back url $(function() { if (window.history && window.history.pushState) { window.history.pushState('', null, './'); $(window).on('popstate', function() { // alert('Back button

Add to browser history without page reload

僤鯓⒐⒋嵵緔 提交于 2019-11-30 17:17:37
Basically, I have a page that contains a form. When a user submits that form, a Javscript function is called and the user is dynamically presented with a new form. At this point, what I would like is for the user to be able to click the browser's back button and be taken back to the first form. Is this possible? Thanks for the quick responses, but I am having trouble getting pushState to work. The HTML still displays "second form" after I click the back button. Here is the code I used to test it: <script> function newPage(){ history.pushState({state:1}, "State 1", "?state=1"); document

Safari Back button not honouring PHP logout session

核能气质少年 提交于 2019-11-30 16:06:28
问题 I've got a logout.php page which ends a user's session and works well and does the following: session_start(); session_unset(); session_destroy(); I've just noticed when testing with Safari that when you logout you can click the back button to return to the previous page which requires authentication but are not prompted. You cannot navigate away from this page without entering the navigation but it should not be displaying the previous page in the first place. So far in my testing this is

Disable browser back button for one page application

故事扮演 提交于 2019-11-30 15:07:43
I need to disable the back button of browser in my single page application. I tried using methods like onhashchange or window.history.forward but they don't work (reason may be that url doesn't get changed here) Please help! Thanks. I work in AngularJS building a Single Page App and I wanted to disable or prevent the back button of the browser, because my app has buttons and anchors for all navegation into my app. I searched and test many codes, and this is the easy to prevent the back button of browsers and the following code worked for me. window.onpopstate = function (e) { window.history

Activity生命周期——Mars Android开发视频之第二季第一集(重)

别等时光非礼了梦想. 提交于 2019-11-30 11:00:17
1· Activity的生命周期(一) 1.1 如何定义多个Activity 1 - 新建一个类,继承Activity package com.example.activiylife; import android.app.Activity; public class SecondActivity extends Activity{ } 2- 重写Activity中的onCreate方法 protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); } 3- 创建布局文件: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <TextView android:id="@+id/textView" android:layout_width="wrap_content" android

How can I detect a user about the exit the page? [closed]

倾然丶 夕夏残阳落幕 提交于 2019-11-30 07:04:20
I would like to detect when a user is about to exit the page, before they click the back button , and do something - for example display a popup. I do not want to prevent the user from leaving the page, but only to grab their attention again. This is already done by Optin Monster , but I want to implement it myself. Where to start? Edit: beforeunload is fired after the user clicked the back or x button. I would like to catch his exit intent , for example when the mouse is moving towards the back button, but before it was clicked. A. Wolff Ouibounce does this. There is a live demo here . npm

Leaving android app with back button

送分小仙女□ 提交于 2019-11-30 05:13:38
I want the users of my android app to leave my app when they press back at a certain activity. Can this be done? 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) { finish(); System.exit(0); } }).setNegativeButton("No", null).show(); } It must be noted as it is mentioned in

Jquery when back button is pressed

亡梦爱人 提交于 2019-11-30 01:48:34
问题 I have a click that changes things on the page when you click it. I was wondering if there was a way to trigger an effect when you press the back button on the browser 回答1: You can sort of do it using the popstate event: window.onpopstate = function() { alert("pop!"); } or in jQuery : $(window).on('popstate', function(event) { alert("pop"); }); However this will also trigger when navigating forward, not only backward. 回答2: Disable back url $(function() { if (window.history && window.history

Add to browser history without page reload

我怕爱的太早我们不能终老 提交于 2019-11-30 00:46:03
问题 Basically, I have a page that contains a form. When a user submits that form, a Javscript function is called and the user is dynamically presented with a new form. At this point, what I would like is for the user to be able to click the browser's back button and be taken back to the first form. Is this possible? Thanks for the quick responses, but I am having trouble getting pushState to work. The HTML still displays "second form" after I click the back button. Here is the code I used to test