java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.admin.myapplication/com.example.admin.myapplication.MainActivity}: java.lang.ClassCastException: android.app.Application cannot be cast to com.example.admin.myapplication.ApplicationContext

Stack Overflow | sumit | 7 months ago
tip
Your exception is missing from the Samebug knowledge base.
Here are the best solutions we found on the Internet.
Click on the to mark the helpful solution and get rewards for you help.
  1. 0

    android get application context from anywhere but its always show class cast exeption i dont knoew how to use

    Stack Overflow | 7 months ago | sumit
    java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.admin.myapplication/com.example.admin.myapplication.MainActivity}: java.lang.ClassCastException: android.app.Application cannot be cast to com.example.admin.myapplication.ApplicationContext

    Root Cause Analysis

    1. java.lang.ClassCastException

      android.app.Application cannot be cast to com.example.admin.myapplication.ApplicationContext

      at com.example.admin.myapplication.MainActivity.onCreate()
    2. com.example.admin
      MainActivity.onCreate
      1. com.example.admin.myapplication.MainActivity.onCreate(MainActivity.java:70)
      1 frame
    3. Android Platform
      ActivityThread.performLaunchActivity
      1. android.app.Activity.performCreate(Activity.java:5933)
      2. android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105)
      3. android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2251)
      3 frames