开启后台 Service 闪退

  • Post author:
  • Post category:其他


04-29 15:36:23.395: E/ActivityThread(15275): Performing stop of activity that is not resumed: {com.example.jarwrite/com.example.jarwrite.MainActivity}

04-29 15:36:23.395: E/ActivityThread(15275): java.lang.RuntimeException: Performing stop of activity that is not resumed: {com.example.jarwrite/com.example.jarwrite.MainActivity}

04-29 15:36:23.395: E/ActivityThread(15275): at android.app.ActivityThread.performStopActivityInner(ActivityThread.java:3136)

04-29 15:36:23.395: E/ActivityThread(15275): at android.app.ActivityThread.handleStopActivity(ActivityThread.java:3223)

04-29 15:36:23.395: E/ActivityThread(15275): at android.app.ActivityThread.access$1100(ActivityThread.java:138)

04-29 15:36:23.395: E/ActivityThread(15275): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1226)

04-29 15:36:23.395: E/ActivityThread(15275): at android.os.Handler.dispatchMessage(Handler.java:102)

04-29 15:36:23.395: E/ActivityThread(15275): at android.os.Looper.loop(Looper.java:136)

04-29 15:36:23.395: E/ActivityThread(15275): at android.app.ActivityThread.main(ActivityThread.java:5034)

04-29 15:36:23.395: E/ActivityThread(15275):

at java.lang.reflect.Method.invokeNative(Native Method)


04-29 15:36:23.395: E/ActivityThread(15275): at java.lang.reflect.Method.invoke(Method.java:515)

04-29 15:36:23.395: E/ActivityThread(15275): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:807)

04-29 15:36:23.395: E/ActivityThread(15275): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:623)

04-29 15:36:23.395: E/ActivityThread(15275): at dalvik.system.NativeStart.main(Native Method)

问题原因:使用反射机制通过String找布局文件时,String里面加了后缀名”.xml”

解决方法:去掉String里的”.xml”

转载于:https://www.cnblogs.com/jinglecode/p/5446642.html