android 判断应用是 在前台运行 还是在后台运行 csdn
展开全部
rt android.app.ActivityManager.RunningAppProcessInfo;
import android.content.Context;
import android.os.Bundle;
/**
* 判断应用程序在前台还是在后台运行
*/
public class MainActivity extends Activity {
private Boolean isActive;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
isActive = isAppOnForeground();
}
import android.content.Context;
import android.os.Bundle;
/**
* 判断应用程序在前台还是在后台运行
*/
public class MainActivity extends Activity {
private Boolean isActive;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
isActive = isAppOnForeground();
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询