android.app.Application无法强制转换为扩展android.app.Application的类

时间:2013-08-29 19:06:32

标签: android classcastexception

我创建了一个扩展android.app.Application

的类

但是每当我尝试通过以下方式实例化该类时:

AppExt appExt = (AppExt) this.getApplication();

抛出上述错误

因为它扩展了android.app.Application类,为什么我会遇到这个错误

1 个答案:

答案 0 :(得分:3)

在AndroidManifest中声明你的类:

<application
            android:name="your.package.AppExt"
相关问题