运行我的安卓程序的时候出现 很抱歉,XXX已停止运行,这是为什么呢?
log日志如下:05-0815:21:51.335:E/AndroidRuntime(19753):FATALEXCEPTION:main05-0815:21:51.33...
log日志如下:
05-08 15:21:51.335: E/AndroidRuntime(19753): FATAL EXCEPTION: main
05-08 15:21:51.335: E/AndroidRuntime(19753): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.client/com.example.client.LocationActivity}: java.lang.ClassCastException: android.app.Application cannot be cast to com.example.client.LocationListener
05-08 15:21:51.335: E/AndroidRuntime(19753): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2344)
05-08 15:21:51.335: E/AndroidRuntime(19753): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2396)
05-08 15:21:51.335: E/AndroidRuntime(19753): at android.app.ActivityThread.access$600(ActivityThread.java:163)
05-08 15:21:51.335: E/AndroidRuntime(19753): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1365)
05-08 15:21:51.335: E/AndroidRuntime(19753): at android.os.Handler.dispatchMessage(Handler.java:107)
05-08 15:21:51.335: E/AndroidRuntime(19753): at android.os.Looper.loop(Looper.java:194)
05-08 15:21:51.335: E/AndroidRuntime(19753): at android.app.ActivityThread.main(ActivityThread.java:5398)
05-08 15:21:51.335: E/AndroidRuntime(19753): at java.lang.reflect.Method.invokeNative(Native Method)
05-08 15:21:51.335: E/AndroidRuntime(19753): at java.lang.reflect.Method.invoke(Method.java:525)
05-08 15:21:51.335: E/AndroidRuntime(19753): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:833)
05-08 15:21:51.335: E/AndroidRuntime(19753): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
05-08 15:21:51.335: E/AndroidRuntime(19753): at dalvik.system.NativeStart.main(Native Method)
05-08 15:21:51.335: E/AndroidRuntime(19753): Caused by: java.lang.ClassCastException: android.app.Application cannot be cast to com.example.client.LocationListener
05-08 15:21:51.335: E/AndroidRuntime(19753): at com.example.client.LocationActivity.onCreate(LocationActivity.java:41)
05-08 15:21:51.335: E/AndroidRuntime(19753): at android.app.Activity.performCreate(Activity.java:5134)
05-08 15:21:51.335: E/AndroidRuntime(19753): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1081)
05-08 15:21:51.335: E/AndroidRuntime(19753): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2308)
05-08 15:21:51.335: E/AndroidRuntime(19753): ... 11 more 展开
05-08 15:21:51.335: E/AndroidRuntime(19753): FATAL EXCEPTION: main
05-08 15:21:51.335: E/AndroidRuntime(19753): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.client/com.example.client.LocationActivity}: java.lang.ClassCastException: android.app.Application cannot be cast to com.example.client.LocationListener
05-08 15:21:51.335: E/AndroidRuntime(19753): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2344)
05-08 15:21:51.335: E/AndroidRuntime(19753): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2396)
05-08 15:21:51.335: E/AndroidRuntime(19753): at android.app.ActivityThread.access$600(ActivityThread.java:163)
05-08 15:21:51.335: E/AndroidRuntime(19753): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1365)
05-08 15:21:51.335: E/AndroidRuntime(19753): at android.os.Handler.dispatchMessage(Handler.java:107)
05-08 15:21:51.335: E/AndroidRuntime(19753): at android.os.Looper.loop(Looper.java:194)
05-08 15:21:51.335: E/AndroidRuntime(19753): at android.app.ActivityThread.main(ActivityThread.java:5398)
05-08 15:21:51.335: E/AndroidRuntime(19753): at java.lang.reflect.Method.invokeNative(Native Method)
05-08 15:21:51.335: E/AndroidRuntime(19753): at java.lang.reflect.Method.invoke(Method.java:525)
05-08 15:21:51.335: E/AndroidRuntime(19753): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:833)
05-08 15:21:51.335: E/AndroidRuntime(19753): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
05-08 15:21:51.335: E/AndroidRuntime(19753): at dalvik.system.NativeStart.main(Native Method)
05-08 15:21:51.335: E/AndroidRuntime(19753): Caused by: java.lang.ClassCastException: android.app.Application cannot be cast to com.example.client.LocationListener
05-08 15:21:51.335: E/AndroidRuntime(19753): at com.example.client.LocationActivity.onCreate(LocationActivity.java:41)
05-08 15:21:51.335: E/AndroidRuntime(19753): at android.app.Activity.performCreate(Activity.java:5134)
05-08 15:21:51.335: E/AndroidRuntime(19753): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1081)
05-08 15:21:51.335: E/AndroidRuntime(19753): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2308)
05-08 15:21:51.335: E/AndroidRuntime(19753): ... 11 more 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询