开发者

What is the 'context' that is being passed into the onUpdate, onEnabled, onDeleted, and onDisabled methods of the AppWidgetProvider?

Is it the ApplicationContext or the ActivityConte开发者_StackOverflow中文版xt of my app? Does it make a difference which one it is?


Is it the ApplicationContext or the ActivityContext of my app?

You should not care. It is a Context, period. Any assumptions you make beyond that are undocumented and subject to change.

That being said, since there is not necessarily an Activity in your entire application, the Context is rather unlikely to be an Activity.


It should be the ActivityContext. Besides your methods should take the format of..

void    onDeleted(Context context, int[] appWidgetIds)

void    onDisabled(Context context)

void    onEnabled(Context context)

void    onReceive(Context context, Intent intent)

void    onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds)

Where context should be

Context myContext

or anything of this nature.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜