今天写anroid时,想获得一个root activity的引用。
ios中这个很简单, [UIApplication sharedApplication].keyWindow 得到window对象,再通过rootViewController属性便可以得到root Controller 的引用。
接触android不久,没发现这样的函数,于是,在root activity中简历了一个类指针 static public MainActivity singleBean; 并在onCreate中对其付值,达到得到引用的效果。
但是,感觉不太规范。。。以后再想。。。