`
fatedgar
  • 浏览: 132147 次
  • 性别: Icon_minigender_1
  • 来自: 安徽
社区版块
存档分类
最新评论
阅读更多
android运行时报错
错误:java.lang.ClassCastException: android.app.Application
你是否有这类代码:
public class MyApp extends Application {
……
}

在activity类中你调用了
MyApp myApp=(MyApp) getApplicationContext();
进行操作。
类型转换异常,子类转换为父类,所以报错

解决方法:
在AndroidManifest.xml文件中application下加上这个就可以了,声明自己的类就行了
<application
       android:name="com.happysys.healthehome.MyApp"
……
分享到:
评论

相关推荐

    没有app的build 导致找不到application.docx

    Android studio导入新项目编译失败

     Android的SharedPreferences的使用

    SharedPreferences是一种轻型的数据存储方式,它的本质是基于XML文件存储key-value键值对数据,通常用来存储一些简单的配置信息。其存储位置在/data/data/&lt;包名&gt;/shared_prefs目录下。SharedPreferences对象本身只能...

    Android代码-AyoLang常用工具类

    初始化在Application.onCreate()里 package com.cowthan.sample; import android.app.Application; import org.ayo.Ayo; public class App extends Application{ public static Application app; @Override ...

    Mastering.OpenCV.Android.Application.Programming.1783988207

    The book ends with a short chapter covering useful Android tips and tricks and some common errors and solutions that people might face while building an application. By the end of the book, readers ...

    AppInstall.rar

    把其它app 放在assets/ 下面打包, 通过系统调用安装这个app //申请安装未知应用权限 ... intent.setDataAndType(uri, "application/vnd.android.package-archive"); Log.i(TAG,"btnAppInstallClick uri="+uri);

    Android代码-安卓路由跳转库

    public class Application extends android.app.Application { public void onCreate() { super.onCreate(); // You can get the shared instance of router via static method `getShared`, after `asShared` ...

    Learning.Android.Application.Testing.1784395331

    Title: Learning Android Application Testing Author: Diego Torres Milano, Paul Blundell Length: 331 pages Edition: 1 Language: English Publisher: Packt Publishing Publication Date: 2015-04-30 ISBN-10: ...

    生活轨迹Android端

    import android.app.Application; import android.content.Context; import android.widget.Toast; public class YLC_APPLICATION extends Application { private static YLC_APPLICATION instance=null; ...

    谈谈Android里的Context的使用

    android:label="@string/app_name" &gt; android:name=".ApplicationDemoActivity" android:label="@string/app_name" &gt; &lt;intent-filter&gt; &lt;action android:name="android.intent.action.MAIN" /&gt; ...

    ImagesWidget.rar

    android:name="android.appwidget.action.APPWIDGET_CONFIGURE" /&gt; android:name=".ImagesWidgetProvider"&gt; android:name="android.appwidget.action.APPWIDGET_UPDATE" /&gt; android:name="android...

    CommonsWare.The.Busy.Coders.Guide.to.Android.Development.Version.8.2.2017

    It will help you more quickly climb the Android learning curve, so you can create the “killer app” you’ve dreamed of…or perhaps just a quick-and-dirty application for you and your friends. ...

    Wrox.Professional.NFC.Application.Development.for.Android.2013

    308 pages Publisher: Wrox;...Professional NFC Application Development for Android offers the clear, concise advice you need to create great applications for this emerging and exciting technology.

    Unable to determine application id: com.android.tools.idea.run.ApkProvisionException: No outputs for

    Unable to determine application id: com.android.tools.idea.run.ApkProvisionException: No outputs for the main artifact of variant:’ 解决方法: 确保在build.gradle文件中设置了applicationId ...

    Android代码-android-app-bootstrap

    android-app-bootstrap ...A starting tutorial for Android application. native-in-practice Output npmcdn.com: android_app_bootstrap-debug.apk License The MIT License (MIT) Copyright (c) 2015 xdf

    Android.Quick.APIs.Reference

    The book is packed with useful information and is a must-have for any mobile or Android app developer or programmer. In the Android Quick APIs Reference, you will find a concise reference to the ...

    lifecycle

    监听生命周期的生命周期,使用方法比官方生命周期简单和支持的场景更多,支持android.app.Activity,...1.android.app.Application 只包含onstart 2.android.support.v4.app.FragmentActivity 3.android.app.Activity

    android 百度地图 定位示例

    android:label="@string/app_name" &gt; 这里需要添加key,创建应用后,会有这个key android:name="com.baidu.lbsapi.API_KEY" android:value="6t2yuIFylnRG7ECj1xHYuelY" /&gt; ..... package com.obtk.mapdemo...

    nordicsemi.android.nrftoolbox(v1.16.5)

    The nRF Toolbox is a container app that stores your Nordic Semiconductor apps for Bluetooth low energy in one location. It contains applications demonstrating BLE profiles: Cycling Speed and Cadence,...

    Android状态保存、用户偏好设置保存、通过universal_image_loder网络加载图片并做图片缓存处理Demo

    2、将MyApplication.java类放入项目,具体个性细节设置在这个类里面设置。 3、在要加载图片并缓存的地方写入下边的代码: //网络获取图片,并加入缓存 new MyApplication().ImageLoaderCache(url, mIvimage); 4、在...

    Testing.and.Securing.Android.Studio.Applications

    This book, beginning with the fundamentals of Android security, will guide you through the process of creating a secure and debugged application. We will look at the Android Studio development ...

Global site tag (gtag.js) - Google Analytics