如何判断android activity是否运行
1个回答
展开全部
判断android activity是否运行雀闭(可见)方法顷御裂如下:
public static boolean isActivityRunning(Context mContext,String activityClassName){
ActivityManager activityManager = (ActivityManager) mContext.getSystemService(Context.ACTIVITY_SERVICE);
List<RunningTaskInfo> info = activityManager.getRunningTasks(1);
if(info != null && info.size() >拆亏 0){
ComponentName component = info.get(0).topActivity;
if(<span style="font-family: Arial, Helvetica, sans-serif;">activityClassName</span>.equals(component.getClassName())){
return true;
}
}
return false;
}
public static boolean isActivityRunning(Context mContext,String activityClassName){
ActivityManager activityManager = (ActivityManager) mContext.getSystemService(Context.ACTIVITY_SERVICE);
List<RunningTaskInfo> info = activityManager.getRunningTasks(1);
if(info != null && info.size() >拆亏 0){
ComponentName component = info.get(0).topActivity;
if(<span style="font-family: Arial, Helvetica, sans-serif;">activityClassName</span>.equals(component.getClassName())){
return true;
}
}
return false;
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |