SoFunction
Updated on 2025-04-07

Simple way to simulate pressing Home button to exit the application (Share)

Simple way to simulate pressing Home button to exit the application (Share)

Updated: April 30, 2017 11:18:21 Submission: jingxian
Below, the editor will bring you a simple method to simulate pressing the Home button to exit the application (share). The editor thinks it is quite good, so I will share it with you now and give you a reference. Let's take a look with the editor

Examples are as follows:

func exitApplication() { 
    let app = ().delegate as! AppDelegate
    let window = 
    dispatch_async(dispatch_get_main_queue(), { 
      (0.5, animations: { 
        window!.alpha = 0
        window?.frame = CGRectMake((window?.)!/2.0, (window?.)!/2.0, 0, 0) 
      }) { (finish) in
        exit(0) 
      } 
    }) 
  } 

The above simple method (sharing) to simulate pressing the Home button to exit the application is all the content I share with you. I hope you can give you a reference and I hope you can support me more.

  • Home button
  • quit

Related Articles

  • Analysis of examples of reading SIM card messages and contact related categories

    This article mainly introduces Android reading SIM card text messages and contact-related categories. It analyzes the functions, usage and precautions of Android reading SIM card text messages and contact-related categories in the form of examples. It has certain reference value. Friends who need it can refer to it.
    2015-10-10
  • SurfaceTexture TextureView SurfaceView GLSurfaceView in Android

    This article mainly introduces the differences between SurfaceTexture TextureView SurfaceView GLSurfaceView in Android. This article introduces you very detailedly and has certain reference value for your study or work. Friends who need it can refer to it.
    2021-09-09
  • Android Service Class and Lifecycle Detailed Introduction

    This article mainly introduces the relevant information about the detailed introduction of Android Service class and life cycle. Friends who need it can refer to it.
    2017-03-03
  • Android programming method to realize popupwindow timing disappear

    This article mainly introduces the method of Android programming to realize popupwindow timing disappearance. Combined with examples, it analyzes the relevant operation techniques of Android using timers to realize popupwindow timing disappearance. Friends who need it can refer to it.
    2018-01-01
  • Android physical key sorting and instance code

    This article mainly introduces the relevant information about Android physical key sorting and instance code. Friends who need it can refer to it.
    2016-10-10
  • Detailed explanation of the implementation of segmented upload of RxJava and Retrofit files

    This article mainly introduces the detailed explanation of the implementation of RxJava plus Retrofit file upload in segments. Friends in need can refer to it for reference. I hope it can be helpful. I wish you more progress and get promoted as soon as possible to get a salary increase.
    2023-01-01
  • Easily implement Android compass function

    This article mainly introduces several key steps to easily implement the Android compass function. Friends who want to implement the compass function should not miss it.
    2015-12-12
  • Three updates of Android SDK fail and their solutions

    This article mainly introduces three update failures and solutions to Android SDK. Friends who need it can refer to it.
    2014-10-10
  • WebView loading web page setting progress bar in Android

    This article mainly introduces the relevant code for setting progress bars for WebView loading web pages in Android. The sample code in the article is introduced in detail and has a certain reference value. Interested friends can refer to it.
    2017-04-04
  • Using Android's OkHttp package to achieve file upload and download based on HTTP protocol

    OkHttp (GitHub homepage/square/okhttp) is an Android third-party HTTP package that has been popular recently. Here we will explain how to use Android's OkHttp package to achieve file upload and download based on HTTP protocol:
    2016-07-07

Latest Comments