【问题标题】:Notify before closing the Android App on user request应用户请求关闭 Android 应用程序前通知
【发布时间】:2015-12-06 22:22:21
【问题描述】:

我的要求是:

              Once my android app is opened, then I will activate bluetooth. On closure of my android app I want to disable bluetooth.

问题是: 我怎么知道用户请求在 android 中以编程方式关闭应用程序?

【问题讨论】:

    标签: android performance android-activity


    【解决方案1】:

    了解 Android 活动生命周期http://developer.android.com/reference/android/app/Activity.html#ActivityLifecycle

    根据您的要求,您似乎想在onDestroy 方法中禁用蓝牙。

    【讨论】:

    • onDestroy 只有在 Activity 关闭/销毁时才会被调用。但我的要求是当应用程序关闭时(用户从前台进程关闭应用程序),我想调用类似 onDestroy 的方法。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-11-07
    • 1970-01-01
    • 1970-01-01
    • 2018-04-01
    相关资源
    最近更新 更多