如何识别应用程序是否在后台运行

时间:2010-11-22 14:13:15

标签: blackberry uiapplication

我有一个应用程序,在单击应用程序图标时(即进入应用程序时)询问密码。然后我设置了UiApplication.getUiApplication()。requestBackground();应用程序在后台运行的位置。

现在如果再次进入应用程序意味着它已经要求输入密码。

帮帮我。

关于, 萨姆帕斯

2 个答案:

答案 0 :(得分:1)

您可以使用UiApplication.getUiApplication()。isForeground()方法来确定您的应用程序是否在前台。

isForeground方法继承自net.rim.device.api.system Application类,它还支持requestForeground和requestBackground方法。

http://www.blackberry.com/developers/docs/4.6.0api/net/rim/device/api/ui/UiApplication.html

答案 1 :(得分:0)

我想您可能对Application.activate()方法感兴趣:

public void activate()

// Handles foregrounding event.

// The system invokes this method when it brings this application 
// to the foreground. By default, this method does nothing. 
// Override this method to perform additional processing 
// when being brought to the foreground.

UiApplication扩展Application,因此您的UiApplication子类中也可以使用此方法。

相关问题