android.app.application can not be cast to android.app.Activity

1,在做dialog 弹框提示的时候,报错了!

android.app.application can not be cast to android.app.Activity

看了一下代码,使用了全局的自定义的application类,但是没有在AndroidManifest.xml中添加该类的声明。也可以把application context 上下文替换成 activity的context文。

2,android.app.Application cannot be cast to myApplication

这个异常是因为在项目中添加了自定义的Application类,但是没有在AndroidManifest.xml中添加该类的声明,调用时编译器会抛出异常: java.lang.ClassCastException: android.app.Application cannot be cast to myApplication

< application

android:label=...

android:name=". myApplication类名">

相关推荐
墨天梦14 小时前
B17_LifecycleLiveData与Flow
android·kotlin
_祝你今天愉快15 小时前
UI核心 - 绘制流程(测量、布局、绘制)
android
冬奇Lab16 小时前
LLM 驱动的自动化测试系列(07):移动端自动化(三)——Mobile-Agent-v3 与自研 GUI-Owl 模型路线
android·人工智能·测试
leobertlan20 小时前
痛苦系列 | DSP-02 频域切片:DTFT与DFT的探索
android·后端
leobertlan21 小时前
痛苦系列 | DSP-01 从连续到离散:DSP基础与采样
android·后端
事圆则缓1 天前
Android 视频压缩上传实战:从 content Uri、转码到断点续传
android
冉冉同学1 天前
AI Agent 开始操作真实手机:移动端自动化的 3 个新考点
android·ai编程
帅得不敢出门1 天前
Android Framework关闭软件低电关机功能测试PMIC低电保护
android
恋猫de小郭1 天前
Flutter + EmbeddingGemma 2,谷歌发布完全端侧的 AI Edge Foresight
android·前端·flutter
墨天梦1 天前
B16_Material主题与可访问交互
android·kotlin·交互