Thanks for the quick reply and thanks for pointing out my error in my
manifest.  Here is the new one, but still having the same issue.  Also
tried getApplication() vs. getApplicationContext().



<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android";
      package="com.arcdroid.Vars"
      android:versionCode="1"
      android:versionName="1.0">


    <application android:icon="@drawable/icon" android:label="@string/
app_name">
        <activity android:name=".HelloApplication"
                  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:name=".MyApp"
       android:icon="@drawable/icon"
   />

</manifest>

On Apr 16, 7:20 am, Mark Murphy <[email protected]> wrote:
> You have not modified your manifest to say you are using your custom
> Application class.
>
> http://developer.android.com/guide/topics/manifest/application-elemen...
>
> You also have an erroneous <activity> element, claiming that MyApp is
> an activity, when it is not.
>
>
>
> On Sat, Apr 16, 2011 at 10:16 AM, ArcDroid <[email protected]> wrote:
> > Hello all,
> > I have tried everything and can't get past this issue.  Here is a my
> > error and the simple code example....
>
> > Using Android 2.2..
>
> >  java.lang.RuntimeException: Unable to start activity
> > ComponentInfo{com.arcdroid.Vars/com.arcdroid.Vars.HelloApplication}:
> > java.lang.ClassCastException: android.app.Application
> > E/AndroidRuntime( 2231):        at
> > android.app.ActivityThread.performLaunchActivity(ActivityThread.java:
> > 1647)
> > E/AndroidRuntime( 2231):        at
> > android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:
> > 1663)
> > E/AndroidRuntime( 2231):        at android.app.ActivityThread.access
> > $1500(ActivityThread.java:117)
> > E/AndroidRuntime( 2231):        at android.app.ActivityThread
> > $H.handleMessage(ActivityThread.java:931)
> > E/AndroidRuntime( 2231):        at
> > android.os.Handler.dispatchMessage(Handler.java:99)
> > E/AndroidRuntime( 2231):        at android.os.Looper.loop(Looper.java:123)
> > E/AndroidRuntime( 2231):        at
> > android.app.ActivityThread.main(ActivityThread.java:3683)
> > E/AndroidRuntime( 2231):        at
> > java.lang.reflect.Method.invokeNative(Native Method)
> > E/AndroidRuntime( 2231):        at
> > java.lang.reflect.Method.invoke(Method.java:507)
> > E/AndroidRuntime( 2231):        at com.android.internal.os.ZygoteInit
> > $MethodAndArgsCaller.run(ZygoteInit.java:839)
> > E/AndroidRuntime( 2231):        at
> > com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
> > E/AndroidRuntime( 2231):        at dalvik.system.NativeStart.main(Native
> > Method)
> > E/AndroidRuntime( 2231): Caused by: java.lang.ClassCastException:
> > android.app.Application
> > E/AndroidRuntime( 2231):        at
> > com.arcdroid.Vars.HelloApplication.onCreate(HelloApplication.java:13)
> > E/AndroidRuntime( 2231):        at
> > android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:
> > 1047)
> > E/AndroidRuntime( 2231):        at
> > android.app.ActivityThread.performLaunchActivity(ActivityThread.java:
> > 1611)
>
> > package com.arcdroid.Vars;
>
> > import android.app.Application;
>
> > public class MyApp extends Application {
>
> >        public MyApp() {
> >                // TODO Auto-generated constructor stub
> >        }
>
> >        private String myState;
>
> >          public String getState(){
> >            return myState;
> >          }
> >          public void setState(String s){
> >            myState = s;
> >          }
>
> > }
>
> > package com.arcdroid.Vars;
>
> > import android.app.Activity;
> > import android.app.Application;
> > import android.os.Bundle;
>
> > public class HelloApplication extends Activity {
> >    /** Called when the activity is first created. */
> >    @Override
> >    public void onCreate(Bundle savedInstanceState) {
> >        super.onCreate(savedInstanceState);
> >        setContentView(R.layout.main);
> >        MyApp appState = ((MyApp)getApplicationContext());
> >           // String state = appState.getState();
>
> >    }
> > }
>
> > <?xml version="1.0" encoding="utf-8"?>
> > <manifest xmlns:android="http://schemas.android.com/apk/res/android";
> >      package="com.arcdroid.Vars"
> >      android:versionCode="1"
> >      android:versionName="1.0">
>
> >    <application android:icon="@drawable/icon" android:label="@string/
> > app_name">
> >        <activity android:name=".HelloApplication"
> >                  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=".MyApp" />
>
> >    </application>
>
> > </manifest>
>
> > Thanks in advance...
> >http://www.arcdroid.com
>
> > --
> > You received this message because you are subscribed to the Google
> > Groups "Android Developers" group.
> > To post to this group, send email to [email protected]
> > To unsubscribe from this group, send email to
> > [email protected]
> > For more options, visit this group at
> >http://groups.google.com/group/android-developers?hl=en
>
> --
> Mark Murphy (a Commons 
> Guy)http://commonsware.com|http://github.com/commonsguyhttp://commonsware.com/blog|http://twitter.com/commonsguy
>
> Warescription: Three Android Books, Plus Updates, One Low Price!

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to