views:

349

answers:

1

For ease of use I want to extend an Android Activity with a certain class to give it extra functionality and then extend my main activity with that class e.g.

class SuperActivity extends Activity {
    //Very nice extra functions
}

//Class defined in the manifest.xml
class ApplicationActivity extends SuperActivity {
    //Start the application
}

is there any way to do this? currently in the above form its giving me an class not found exception..

Logcat:

10-08 12:23:28.316: ERROR/AndroidRuntime(678): Uncaught handler: thread main exiting due to uncaught exception
10-08 12:23:28.336: ERROR/AndroidRuntime(678): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{ntx.app/ntx.app.AppActivity}: java.lang.ClassNotFoundException: ntx.app.AppActivity in loader dalvik.system.PathClassLoader@437601e8
10-08 12:23:28.336: ERROR/AndroidRuntime(678):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2324)
10-08 12:23:28.336: ERROR/AndroidRuntime(678):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2417)
10-08 12:23:28.336: ERROR/AndroidRuntime(678):     at android.app.ActivityThread.access$2100(ActivityThread.java:116)
10-08 12:23:28.336: ERROR/AndroidRuntime(678):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1794)
10-08 12:23:28.336: ERROR/AndroidRuntime(678):     at android.os.Handler.dispatchMessage(Handler.java:99)
10-08 12:23:28.336: ERROR/AndroidRuntime(678):     at android.os.Looper.loop(Looper.java:123)
10-08 12:23:28.336: ERROR/AndroidRuntime(678):     at android.app.ActivityThread.main(ActivityThread.java:4203)
10-08 12:23:28.336: ERROR/AndroidRuntime(678):     at java.lang.reflect.Method.invokeNative(Native Method)
10-08 12:23:28.336: ERROR/AndroidRuntime(678):     at java.lang.reflect.Method.invoke(Method.java:521)
10-08 12:23:28.336: ERROR/AndroidRuntime(678):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:791)
10-08 12:23:28.336: ERROR/AndroidRuntime(678):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:549)
10-08 12:23:28.336: ERROR/AndroidRuntime(678):     at dalvik.system.NativeStart.main(Native Method)
10-08 12:23:28.336: ERROR/AndroidRuntime(678): Caused by: java.lang.ClassNotFoundException: ntx.app.AppActivity in loader dalvik.system.PathClassLoader@437601e8
10-08 12:23:28.336: ERROR/AndroidRuntime(678):     at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243)
10-08 12:23:28.336: ERROR/AndroidRuntime(678):     at java.lang.ClassLoader.loadClass(ClassLoader.java:573)
10-08 12:23:28.336: ERROR/AndroidRuntime(678):     at java.lang.ClassLoader.loadClass(ClassLoader.java:532)
10-08 12:23:28.336: ERROR/AndroidRuntime(678):     at android.app.Instrumentation.newActivity(Instrumentation.java:1097)
10-08 12:23:28.336: ERROR/AndroidRuntime(678):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2316)
10-08 12:23:28.336: ERROR/AndroidRuntime(678):     ... 11 more

The error doesn't occur when I let the AppActivity extend android.app.Activity

A: 

Solved the problem, I added a project dependency but instead I should have directly added the .jar file..

Had nothing to do with dependencies, there was an uncaught exception in the code of the superclass which broke it.

MrThys