在service中的BroadcasReceiver遇到no empty constructor错误
来源:互联网 发布:国外网络手游 编辑:程序博客网 时间:2024/05/28 17:08
出自我另一博客:http://segmentfault.com/blog/hsdaobeigouzhui/1190000000681288
Logcat提示:
Process: com.lu.times.times, PID: 7551 java.lang.RuntimeException: Unable to instantiate receiver com.lu.times.service.TimesService$LockScreenReceiver: java.lang.InstantiationException: can't instantiate class com.lu.times.service.TimesService$LockScreenReceiver; no empty constructor at android.app.ActivityThread.handleReceiver(ActivityThread.java:2823) at android.app.ActivityThread.access$1700(ActivityThread.java:156) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1440) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:157) at android.app.ActivityThread.main(ActivityThread.java:5872) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:515) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:858) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:674) at de.robv.android.xposed.XposedBridge.main(XposedBridge.java:132) at dalvik.system.NativeStart.main(Native Method) Caused by: java.lang.InstantiationException: can't instantiate class com.lu.times.service.TimesService$LockScreenReceiver; no empty constructor at java.lang.Class.newInstanceImpl(Native Method) at java.lang.Class.newInstance(Class.java:1208) at android.app.ActivityThread.handleReceiver(ActivityThread.java:2818) at android.app.ActivityThread.access$1700(ActivityThread.java:156) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1440) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:157) at android.app.ActivityThread.main(ActivityThread.java:5872) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:515) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:858) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:674) at de.robv.android.xposed.XposedBridge.main(XposedBridge.java:132) at dalvik.system.NativeStart.main(Native Method)
其实很简单啦,内部的broadcastReceiver需要被动态注册,或者是static类。
这样就OK了,我比较喜欢~
private void registerReceiver(){ xxxReceiver = new xxxReceiver(); IntentFilter filter = new IntentFilter(); filter.addAction("xxxx"); }
0 0
- 在service中的BroadcasReceiver遇到no empty constructor错误
- 在service中的BroadcasReceiver遇到no empty constructor错误
- Android广播错误.MainActivity$MyReceiver; no empty constructor
- Android 内部类广播错误.MainActivity$MyReceiver; no empty constructor
- java.lang.InstantiationException:no empty constructor解决方法
- TypeError: this constructor takes no arguments(Python 学习遇到的错误1)
- 在写Mybatis时遇到的问题:No constructor found in 包名+类名
- json封装过程中的No parameterless constructor defined for this object.错误
- No constructor found错误 mybatis笔记
- 关于has no default constructor的错误
- MyBatis-Mapper中错误No constructor found...
- No constructor find in...及NullPointerException错误
- vc++ 编译错误“no appropriate default constructor available”解决方法
- 【error C2512】VC++编译错误 no appropriate default constructor available
- vc++ 编译错误“no appropriate default constructor available”解决方法
- C2512 : no appropriate default constructor available 的另一种错误原因
- There is no default constructor available in xxx错误引发
- 错误总结之no appropriate constructor in class
- Using the Android RecognizerIntent with a bluetooth headset
- 1
- Add Two Numbers
- MyEclipse中SVN的使用方法
- acdream contest 1131 Burning Bridges
- 在service中的BroadcasReceiver遇到no empty constructor错误
- 解决dedecms的php.ini register_globals must is Off!
- HTC T328W刷机包 仿三星S5 UI美化 精简 S5下拉
- 链表 总结
- 笔试题目解答
- SETI--后缀数组
- iOS开发 剖析网易新闻标签栏视图切换(addChildViewController属性介绍)
- 深入理解 HashMap 加载因子 loadFactor
- 通用基础的CSS样式