http://blog.csdn.net/zhangjm123/article/details/7978909
用静态注册内部类广播出现异常
- 09-14 11:31:25.576: E/AndroidRuntime(3391):
- FATAL EXCEPTION: main
- 09-14 11:31:25.576: E/AndroidRuntime
- (3391): java.lang.RuntimeException: Unable to instantiate
- receiver com.jtd.service.Service$InsideService:
- java.lang.InstantiationException: can't instantiate class
- com.jtd.service.Service$InsideService; no empty
- constructor
将内部类改成static class
- public class Service {
- public static class InsideService extends BroadcastReceiver {
- @Override
- public void onReceive(Context context, Intent intent) {
- Log.e("Service", "..onReceive..0914");
- }
- }
- }
在AndroidManifest.xml中定义
- <receiver android:name="com.jtd.service.Service$InsideService" >
- <intent-filter>
- <action android:name="com.jtd.service.Service.InsideService" />
- </intent-filter>
- </receiver>
内部类加入$符号