Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8257931
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T02:22:01+00:00 2026-06-08T02:22:01+00:00

I am trying to put my list of custom objects in the application class

  • 0

I am trying to put my list of custom objects in the application class to access my data in multiple activities. But something doesn’t work, and I don’t know what’s going wrong.

This is what I’m doing:

AssetManager assetManager = getAssets();
InputStream inputStream = null;
try {
    inputStream = assetManager.open("myJsonFile.json");
} catch (IOException e) {
    Log.e("tag", e.getMessage());
}
ObjectMapper objectMapper = new ObjectMapper();
try {

     List<JJsonResponse> jsonResponse = objectMapper.readValue(inputStream, new TypeReference<List<JJsonResponse>>() { });
     Log.i("tijdlog","einde parsing" );
     final  List<JJsonResponse> myGlobalVariable = jsonResponse;
      ((ApplicationController)getApplication()).setGlobalVariable(myGlobalVariable);

where JJsonResponse is some custom object. Without the last part, everything worked just fine.

My ApplicationController class:

    public class ApplicationController extends Application {

    private List<JJsonResponse> venueController;

    public List<JJsonResponse> getGlobalVariable() {
        return venueController;
    }

    public void setGlobalVariable(List<JJsonResponse> globalVariable) {
        this.venueController = globalVariable;    
    }

    @Override
    public void onCreate() {

    }
}

when running the program crashes.
error log:

07-20 14:06:09.487: W/dalvikvm(6668): threadid=1: thread exiting with uncaught exception (group=0x400259f8)
07-20 14:06:09.497: E/AndroidRuntime(6668): FATAL EXCEPTION: main
07-20 14:06:09.497: E/AndroidRuntime(6668): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.jacksonrecipes.testapp/com.jacksonrecipes.testapp.Main}: java.lang.ClassCastException: android.app.Application
07-20 14:06:09.497: E/AndroidRuntime(6668):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2787)
07-20 14:06:09.497: E/AndroidRuntime(6668):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2803)
07-20 14:06:09.497: E/AndroidRuntime(6668):     at android.app.ActivityThread.access$2300(ActivityThread.java:135)
07-20 14:06:09.497: E/AndroidRuntime(6668):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2136)
07-20 14:06:09.497: E/AndroidRuntime(6668):     at android.os.Handler.dispatchMessage(Handler.java:99)
07-20 14:06:09.497: E/AndroidRuntime(6668):     at android.os.Looper.loop(Looper.java:144)
07-20 14:06:09.497: E/AndroidRuntime(6668):     at android.app.ActivityThread.main(ActivityThread.java:4937)
07-20 14:06:09.497: E/AndroidRuntime(6668):     at java.lang.reflect.Method.invokeNative(Native Method)
07-20 14:06:09.497: E/AndroidRuntime(6668):     at java.lang.reflect.Method.invoke(Method.java:521)
07-20 14:06:09.497: E/AndroidRuntime(6668):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:858)
07-20 14:06:09.497: E/AndroidRuntime(6668):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
07-20 14:06:09.497: E/AndroidRuntime(6668):     at dalvik.system.NativeStart.main(Native Method)
07-20 14:06:09.497: E/AndroidRuntime(6668): Caused by: java.lang.ClassCastException: android.app.Application
07-20 14:06:09.497: E/AndroidRuntime(6668):     at com.jacksonrecipes.testapp.Main.onCreate(Main.java:52)
07-20 14:06:09.497: E/AndroidRuntime(6668):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1069)
07-20 14:06:09.497: E/AndroidRuntime(6668):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2751)

I made the variable final cause I thought it might have something to do with that, but that didn’t work. Does anyone know what the uncaught exception might be and how to solve my problem?

edit: Forgot to show my manifest, I don’t know if that’s right so I added it:

   <application
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name" >
    <activity
        android:name=".Main"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
</application>
<application 
    android:label="@string/app_name" 
    android:name=".ApplicationController" 
    />
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T02:22:04+00:00Added an answer on June 8, 2026 at 2:22 am

    You should define the name of your Application in your Android project’s Manifest.xml to ApplicationController something like this:

    <application
        android:name=".ApplicationController"
    ......
    

    EDIT You have supplied two applications in your manifest. Change your Manifest from this:

    <application
       android:icon="@drawable/ic_launcher"
       android:label="@string/app_name" >
    <activity
        android:name=".Main"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    </application>
    <application 
       android:label="@string/app_name" 
       android:name=".ApplicationController" 
    />
    

    to this:

    <application
       android:icon="@drawable/ic_launcher"
       android:label="@string/app_name"
       android:name=".ApplicationController"  >
    <activity
        android:name=".Main"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    </application>
    

    And i think you will be ok

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to put some data in a list of custom objects. One
I'm trying to put some custom list adapters into their own classes to make
Hello everyone I've been trying to put some objects in an ASP.NET list box
Im trying to make a textarea where you put in a list of things,
I'm trying to create a custom search but getting stuck. What I want is
I'm trying to put a custom ListView in a Dialog . My code is
I'm trying to put a list of buttons side by side so they all
I'm trying to create a custom ListBox. That receives a list with three properties:
I am trying to put a list under 2 editTexts and 2 buttons. I
I'm using JSF/Facelets, and I'm trying to iterate over some Document objects (custom object)

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.