onUpdate() intilized variable are null in onReceive of widget class

后端 未结 1 1869
既然无缘
既然无缘 2021-01-16 01:34

I initialize one variable in an onUpdate() method and after that I call onReceive() function which runs fine but cannot access varible set in onUpdate() method. Why is that

1条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-16 01:54

    for a AppWidgetReceiver , first onReceive() will be called and then based on the Action received, it will call onUpdate(...) method. so here you are initializing state in onUpdate() which will be called after onReceive(), thus state is null in onReceive().

    0 讨论(0)
提交回复
热议问题