次の方法を使用して、別のアプリケーションに切り替えようとしています。
private void switchAcitivty() {
Intent intent = new Intent();
intent.setClass(this, TeleJokeActivity.class);
startActivity(intent);
}
しかし、次のエラーが発生します。
04-10 03:05:51.901: E/AndroidRuntime(831): FATAL EXCEPTION: main
04-10 03:05:51.901: E/AndroidRuntime(831): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.telejoke.mo/com.telejoke.mo.TeleJokeActivity}: java.lang.NullPointerException
04-10 03:05:51.901: E/AndroidRuntime(831): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2585)
04-10 03:05:51.901: E/AndroidRuntime(831): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
04-10 03:05:51.901: E/AndroidRuntime(831): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
04-10 03:05:51.901: E/AndroidRuntime(831): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
04-10 03:05:51.901: E/AndroidRuntime(831): at android.os.Handler.dispatchMessage(Handler.java:99)
04-10 03:05:51.901: E/AndroidRuntime(831): at android.os.Looper.loop(Looper.java:123)
04-10 03:05:51.901: E/AndroidRuntime(831): at android.app.ActivityThread.main(ActivityThread.java:4627)
04-10 03:05:51.901: E/AndroidRuntime(831): at java.lang.reflect.Method.invokeNative(Native Method)
04-10 03:05:51.901: E/AndroidRuntime(831): at java.lang.reflect.Method.invoke(Method.java:521)
04-10 03:05:51.901: E/AndroidRuntime(831): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
04-10 03:05:51.901: E/AndroidRuntime(831): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
04-10 03:05:51.901: E/AndroidRuntime(831): at dalvik.system.NativeStart.main(Native Method)
04-10 03:05:51.901: E/AndroidRuntime(831): Caused by: java.lang.NullPointerException
04-10 03:05:51.901: E/AndroidRuntime(831): at android.app.Activity.findViewById(Activity.java:1637)
04-10 03:05:51.901: E/AndroidRuntime(831): at com.telejoke.mo.TeleJokeActivity.<init>(TeleJokeActivity.java:11)
04-10 03:05:51.901: E/AndroidRuntime(831): at java.lang.Class.newInstanceImpl(Native Method)
04-10 03:05:51.901: E/AndroidRuntime(831): at java.lang.Class.newInstance(Class.java:1429)
04-10 03:05:51.901: E/AndroidRuntime(831): at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
04-10 03:05:51.901: E/AndroidRuntime(831): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2577)
04-10 03:05:51.901: E/AndroidRuntime(831): ... 11 more
なぜ私が得ているのかわからないNullPointerException
。