先看代码:
public class ZonePicker {
public static class SetDefaultTimeZone extends BroadcastReceiver{
@Override
public void onReceive(Context context, Intent intent) {
// TODO Auto-generated method stub
if (intent.getAction().equals(Intent.ACTION_BOOT_COMPLETED)) {
}
}
}
}
xml文件:
<receiver android:name="ZonePicker$SetDefaultTimeZone" android:enabled="true">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED"></action>
</intent-filter>
</receiver>
在有的时候会用到BroadcastReceiver内部类,使用静态注册方式注册BroadcastReceiver,但是会出现不能加载你继承的BroadcastReceiver类,解决办法是你需要把你自己写的
类(在这里是:SetDefaultTimeZone)声明为静态的。