Question

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){
}
Was it helpful?

Solution

Override onEnabled instead of using a static block.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top