gpt4 book ai didi

代码中出现 java.classCastException

转载 作者:行者123 更新时间:2023-12-01 14:24:39 24 4
gpt4 key购买 nike

指针应用程序扩展了应用程序。

private pointerApplication getPoa() {
pointerApplication poa = (pointerApplication) getApplication();
return poa;
}

错误:

   06-23 11:21:30.276: E/AndroidRuntime(1374): FATAL EXCEPTION: main
06-23 11:21:30.276: E/AndroidRuntime(1374): java.lang.ClassCastException: android.app.Application cannot be cast to com.startup.tryingpointers.pointerApplication
06-23 11:21:30.276: E/AndroidRuntime(1374): at com.startup.tryingpointers.AddsubjectList.addSubject(AddsubjectList.java:49)
06-23 11:21:30.276: E/AndroidRuntime(1374): at com.startup.tryingpointers.AddsubjectList$1.onClick(AddsubjectList.java:33)
06-23 11:21:30.276: E/AndroidRuntime(1374): at android.view.View.performClick(View.java:4204)
06-23 11:21:30.276: E/AndroidRuntime(1374): at android.view.View$PerformClick.run(View.java:17355)
06-23 11:21:30.276: E/AndroidRuntime(1374): at android.os.Handler.handleCallback(Handler.java:725)
06-23 11:21:30.276: E/AndroidRuntime(1374): at android.os.Handler.dispatchMessage(Handler.java:92)
06-23 11:21:30.276: E/AndroidRuntime(1374): at android.os.Looper.loop(Looper.java:137)
06-23 11:21:30.276: E/AndroidRuntime(1374): at android.app.ActivityThread.main(ActivityThread.java:5041)
06-23 11:21:30.276: E/AndroidRuntime(1374): at java.lang.reflect.Method.invokeNative(Native Method)
06-23 11:21:30.276: E/AndroidRuntime(1374): at java.lang.reflect.Method.invoke(Method.java:511)
06-23 11:21:30.276: E/AndroidRuntime(1374): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
06-23 11:21:30.276: E/AndroidRuntime(1374): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
06-23 11:21:30.276: E/AndroidRuntime(1374): at dalvik.system.NativeStart.main(Native Method)

最佳答案

确保在 AndroidManifest.xml 中,您已使用正确的类名声明 application 标记的 android:name 属性:

<application
android:name=".pointerApplication" >
</application>

关于代码中出现 java.classCastException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17260405/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com