机器人:如何检查,如果应用程序在后台运行 [英] android:how to check if application is running in background

查看:204
本文介绍了机器人:如何检查,如果应用程序在后台运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是新手到Android。我的客户端服务器应用程序。服务器不断每一分钟后,在客户端发送更新通知到客户端我的应用程序接收这些更新和使用吐司显示。但现在我的问题是,每当我的客户端应用程序进入后台服务器不断发送更新通知,我的客户端显示为如果应用程序是在前台。我没有得到如何检查应用程序在后台运行。

I am newbie to android. I have client server based application. Server keeps on sending the update notifications to client after every single minute and at client side my app receive those updates and display it using Toast. But now my problem is whenever my client app goes into the background server keeps on sending the update notifications and my client display it as if the application is in foreground. I am not getting how to check that application is running in background.

推荐答案

<一个href="http://developer.android.com/guide/topics/fundamentals.html#lcycles">http://developer.android.com/guide/topics/fundamentals.html#lcycles是一个Android应用程序的生命周期的描述。

http://developer.android.com/guide/topics/fundamentals.html#lcycles is a description of the Life Cycle of an android application.

该方法的onPause()被调用时,活动进入后台。所以,你可以禁用更新通知,这种方法。

The method onPause() gets called when the activity goes into the background. So you can deactivate the update notifications in this method.

这篇关于机器人:如何检查,如果应用程序在后台运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆