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 7597181
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T22:05:53+00:00 2026-05-30T22:05:53+00:00

Im getting a ClassCastException that shouldnt be happening. Here is the code: TwitterApplication ta

  • 0

Im getting a ClassCastException that shouldnt be happening.
Here is the code:

TwitterApplication ta = (TwitterApplication)getApplication();
    OAuthProvider p = ta.getProvider();

As you see im trying to cast TwitterApplication from an Application.

public class TwitterApplication extends Application {

private Twitter twitter;

public Twitter getTwitter(){
    return this.twitter;
}

public void setTwitter(Twitter t){
    this.twitter = t;
}

private OAuthProvider provider;
private CommonsHttpOAuthConsumer consumer;

public void setProvider(OAuthProvider oap){
    this.provider = oap;
}

public OAuthProvider getProvider(){
    return this.provider;
}

public void setConsumer(CommonsHttpOAuthConsumer c){
    this.consumer = c;
}

public CommonsHttpOAuthConsumer getConsumer(){
    return this.consumer;
}

As you see here, it extends application.

Is my casting knowledge faulty?
Why am I getting this error?
Thanks

EDIT:
Full Stacktrace:

03-03 15:45:09.275: ERROR/AndroidRuntime(3192): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.laytproducts.IN/com.laytproducts.IN.TwitterUpdate}: java.lang.ClassCastException: android.app.Application
03-03 15:45:09.275: ERROR/AndroidRuntime(3192):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1696)
03-03 15:45:09.275: ERROR/AndroidRuntime(3192):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1716)
03-03 15:45:09.275: ERROR/AndroidRuntime(3192):     at android.app.ActivityThread.access$1500(ActivityThread.java:124)
03-03 15:45:09.275: ERROR/AndroidRuntime(3192):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:968)
03-03 15:45:09.275: ERROR/AndroidRuntime(3192):     at android.os.Handler.dispatchMessage(Handler.java:99)
03-03 15:45:09.275: ERROR/AndroidRuntime(3192):     at android.os.Looper.loop(Looper.java:130)
03-03 15:45:09.275: ERROR/AndroidRuntime(3192):     at android.app.ActivityThread.main(ActivityThread.java:3806)
03-03 15:45:09.275: ERROR/AndroidRuntime(3192):     at java.lang.reflect.Method.invokeNative(Native Method)
03-03 15:45:09.275: ERROR/AndroidRuntime(3192):     at java.lang.reflect.Method.invoke(Method.java:507)
03-03 15:45:09.275: ERROR/AndroidRuntime(3192):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
03-03 15:45:09.275: ERROR/AndroidRuntime(3192):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
03-03 15:45:09.275: ERROR/AndroidRuntime(3192):     at dalvik.system.NativeStart.main(Native Method)
03-03 15:45:09.275: ERROR/AndroidRuntime(3192): Caused by: java.lang.ClassCastException: android.app.Application
03-03 15:45:09.275: ERROR/AndroidRuntime(3192):     at com.laytproducts.IN.TwitterUpdate.getConsumerProvider(TwitterUpdate.java:148)
03-03 15:45:09.275: ERROR/AndroidRuntime(3192):     at com.laytproducts.IN.TwitterUpdate.onCreate(TwitterUpdate.java:117)
03-03 15:45:09.275: ERROR/AndroidRuntime(3192):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
03-03 15:45:09.275: ERROR/AndroidRuntime(3192):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1660)
03-03 15:45:09.275: ERROR/AndroidRuntime(3192):     ... 11 more

Manifest:

 <uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.GET_ACCOUNTS"></uses-permission>

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

    <activity android:name=".Main" />

    <activity android:name=".FBUpdate">
        <intent-filter>
            <action android:name="com.laytproducts.IN.WidgetAct.ACTION_WIDGET_FB" />
        </intent-filter>
    </activity>
    <activity android:name=".TwitterUpdate">
        <intent-filter>
            <action android:name="com.laytproducts.IN.WidgetAct.ACTION_WIDGET_TWITTER" />
        </intent-filter>
    </activity>

    <application android:name="TwitterApplication" />

    <receiver android:name=".WidgetAct">
        <intent-filter>
            <action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
        </intent-filter>
        <meta-data android:name="android.appwidget.provider"
            android:resource="@xml/winfo"/>
    </receiver>
</application>
  • 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-05-30T22:05:54+00:00Added an answer on May 30, 2026 at 10:05 pm

    You will get an error if the concrete class returned by getApplication() is not actually a TwitterApplication object.

    Have you amended your Android manifest file so that it uses this TwitterApplication class? If not, you will need to do. Simply extending Application is not enough – you must tell Android to use the TwitterApplication concrete class.

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

Sidebar

Related Questions

I am getting a ClassCastException for org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter In the logs I see that my
I am getting below error whilst trying to persist an object that has a
Started getting a ClassCastException in a widget I've been working on that I'm not
I'm getting a ClassCastException in the below code, which doesn't make much sense to
I keep getting a ClassCastException Exception in thread main java.lang.ClassCastException: java.lang.String cannot be cast
I'm getting the following exception. Caused by: java.lang.ClassCastException: java.math.BigInteger cannot be cast to java.lang.Integer
Getting the subdomain from a URL sounds easy at first. http://www.domain.example Scan for the
Getting the above error in following code. How to rectify it. Thanks. Please look
Getting a 'marshal data too short' error when trying to install the mysql gem
Getting Json from the Server and displaying it in the grid is relatively straight

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.