Code example for HandlerThread

Methods: getLooperstart

    private static Handler sWorkerQueue;
    private static WeatherDataProviderObserver sDataObserver;
    public WeatherWidgetProvider() { 
        // Start the worker thread 
        sWorkerThread = new HandlerThread("WeatherWidgetProvider-worker");
        sWorkerQueue = new Handler(sWorkerThread.getLooper());
    public void onEnabled(Context context) {
        // Register for external updates to the data to trigger an update of the widget.  When using 
        // content providers, the data is often updated via a background service, or in response to 
        // user interaction in the main app.  To ensure that the widget always reflects the current 
        // state of the data, we must listen for changes and update ourselves accordingly. 
        final ContentResolver r = context.getContentResolver();
        if (sDataObserver == null) {
            final AppWidgetManager mgr = AppWidgetManager.getInstance(context);
            final ComponentName cn = new ComponentName(context, WeatherWidgetProvider.class);