Android中 如何判断现在所处的界面是否为home主桌面

public List<RunningTaskInfo> getActivity() { 
	try { 
		ActivityManager activityManager = (ActivityManager) this.getSystemService(Context.ACTIVITY_SERVICE); 
		List<RunningTaskInfo> taskInfos = activityManager .getRunningTasks(10);
		ActivityManager am = (ActivityManager) this.getSystemService(Context.ACTIVITY_SERVICE); 
		ComponentName cn = am.getRunningTasks(2).get(0).topActivity; 
		Log.i("OTH","TOP___ACTIVITY === " + cn); 
		return taskInfos; 
	} catch (SecurityException e) { 
		e.printStackTrace(); 
	} 
	return null; 
}

之前写的这个博文,后来发现,在应用程序列表的那个界面也是在launcher上的,所以以上代码在处于应用程序列表的界面的时候返回的也是true的 >_<

后来又找了不少资料,了解了下launcher的启动过程,这样也就可以解决以上问题啦~~

大家可以参考下我的下一篇blog哈~     http://blog.csdn.net/listening_music/article/details/7167642

你可能感兴趣的:(Android中 如何判断现在所处的界面是否为home主桌面)