android.app.Application不能转换为类扩展android.app.Application [英] android.app.Application cannot be cast to class extending android.app.Application
本文介绍了android.app.Application不能转换为类扩展android.app.Application的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我创建一个扩展android.app.Application类
I have created a class that extends android.app.Application
然而,每当我试图通过实例化类:
However whenever I try to instantiate the class by:
AppExt appExt = (AppExt) this.getApplication();
抛出上述错误
由于它扩展了android.app.Application类为什么我会遇到这个错误
Since it extends the android.app.Application class why would I encounter this error
推荐答案
您声明类AndroidManifest:
Declare your class in AndroidManifest:
<application
android:name="your.package.AppExt"
这篇关于android.app.Application不能转换为类扩展android.app.Application的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文