Search code examples
androidwidgetandroid-contextappwidgetprovider

How can get context in my Own method or static block?


I am in AppWidgetProvider class. I want to call a static block before any callback method, but I need the context inside my static block. How can I get that?

Below is my code:

public class widgetClass extends AppWidgetProvider {

    static
{
// here i want the context

}

    @Override
public void onUpdate(Context context, AppWidgetManager appWidgetManager,
        int[] appWidgetIds){
}

Solution

  • Override onEnabled instead of using a static block.