进程被杀后,Android onEnabled()生命周期

时间:2023-01-26 09:06:56

According to the documentation the lifecycle of the AppWidgetProvider class is managed by the Android platform. The documentation also states that the lifecycle method onEnabled() is only called once. But how about widgets that were removed because the Android platfrom reclaimed its memory? In that case when the widget is activated again (e.g. some intent was received, or someone clicked on the widget), will the onEnabled() method be called again?

根据文档,AppWidgetProvider类的生命周期由Android平台管理。该文档还指出onEnabled()的生命周期方法只被调用一次。但是因为Android平台重新开始记忆而被删除的小部件呢?在那种情况下,当窗口小部件再次被激活时(例如,收到某个意图,或者有人点击了窗口小部件),是否会再次调用onEnabled()方法?

1 个解决方案

#1


0  

NO! Answer is Simple No. I have started working on widgets recently. and i have learned the basics and according to that . the onEnabled()is jst like onCreate Method whenever you close and reopen the widget/activity the onEnabled/onCreate method is called.

没有!答案很简单。我最近开始研究小部件。我已经学会了基础知识并据此而已。每当你关闭并重新打开小部件/活动时,onEnabled()就像onCreate方法一样,调用onEnabled / onCreate方法。

onEnabled(Context context) : Called when the first App Widget is created. Global initialization should take place here, if applicable.

onEnabled(Context context):在创建第一个App Widget时调用。如果适用,应在此处进行全局初始化。

Reference: http://www.developer.com/ws/article.php/3833306/Creating-a-Home-Screen-App-Widget-on-Android.htm

参考:http://www.developer.com/ws/article.php/3833306/Creating-a-Home-Screen-App-Widget-on-Android.htm

Thanks: Hopefully i Helped U. Dont Mark this Answer as Correct So that other also knows the correct Answer!

谢谢:希望我帮助你。不要将此答案标记为正确,以便其他人也知道正确答案!

#1


0  

NO! Answer is Simple No. I have started working on widgets recently. and i have learned the basics and according to that . the onEnabled()is jst like onCreate Method whenever you close and reopen the widget/activity the onEnabled/onCreate method is called.

没有!答案很简单。我最近开始研究小部件。我已经学会了基础知识并据此而已。每当你关闭并重新打开小部件/活动时,onEnabled()就像onCreate方法一样,调用onEnabled / onCreate方法。

onEnabled(Context context) : Called when the first App Widget is created. Global initialization should take place here, if applicable.

onEnabled(Context context):在创建第一个App Widget时调用。如果适用,应在此处进行全局初始化。

Reference: http://www.developer.com/ws/article.php/3833306/Creating-a-Home-Screen-App-Widget-on-Android.htm

参考:http://www.developer.com/ws/article.php/3833306/Creating-a-Home-Screen-App-Widget-on-Android.htm

Thanks: Hopefully i Helped U. Dont Mark this Answer as Correct So that other also knows the correct Answer!

谢谢:希望我帮助你。不要将此答案标记为正确,以便其他人也知道正确答案!