Android HandlerThread - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Android HandlerThread class.

This code example shows how to use the following methods: getLooper, start
        mStorageManager = (StorageManager) context.getSystemService(Context.STORAGE_SERVICE);
        final boolean connected = mStorageManager.isUsbMassStorageConnected();
        if (DEBUG) Slog.d(TAG, String.format( "Startup with UMS connection %s (media state %s)",
                mUmsAvailable, Environment.getExternalStorageState()));
         
        HandlerThread thr = new HandlerThread("SystemUI StorageNotification");
        thr.start();
        mAsyncEventHandler = new Handler(thr.getLooper());
 
        onUsbMassStorageConnectionChanged(connected);
    } 
 
    /* 
     * @override com.android.os.storage.StorageEventListener 
     */ 
    @Override 
    public void onUsbMassStorageConnectionChanged(final boolean connected) {
        mAsyncEventHandler.post(new Runnable() {
            @Override 
            public void run() { 
Full Snippet Info
8
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: start
	/** 
	 * This method initializes the aysnc screenshot saving logic 
	 */ 
	private void initScreenShotSaver() { 
		if(screenShotSaverThread == null || screenShotSaver == null) {
			screenShotSaverThread = new HandlerThread("ScreenShotSaver");
			screenShotSaverThread.start();
			screenShotSaver = new ScreenShotSaver(screenShotSaverThread);
		} 
	} 
 
	/**  
	 * This is the thread which causes a screenshot sequence to happen 
	 * in parallel with testing. 
	 */ 
	private class ScreenshotSequenceThread extends Thread {
		private int seqno = 0;
 
		private String name;
		private int quality;
Full Snippet Info
7
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: getLooper, start
 * Helper class for managing the background thread used to perform io operations 
 * and handle async broadcasts. 
 */ 
public final class AsyncHandler { 
 
    private static final HandlerThread sHandlerThread = new HandlerThread("AsyncHandler");
 
    private static final Handler sHandler;
 
    static { 
        sHandlerThread.start();
        sHandler = new Handler(sHandlerThread.getLooper());
    } 
 
    /* This class is never initiated */ 
    private AsyncHandler() { 
    } 
 
    /** 
     * @param r The {@link Runnable} to execute. 
Full Snippet Info
7
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: getLooper, start
            handler = null;
        } 
    } 
 
    public void start() { 
        handlerThread = new HandlerThread("TDListenerHandlerThread");
        handlerThread.start();
        Looper looper = handlerThread.getLooper();
        handler = new Handler(looper);
        thread = new Thread(this);
        thread.start();
    } 
 
    public void stop() { 
        httpServer.notifyStop();
    } 
 
    public void onServerThread(Runnable r) {
        handler.post(r);
    } 
Full Snippet Info
5
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: getLooper, start
    private static Handler sWorkerQueue;
    private static WeatherDataProviderObserver sDataObserver;
 
    public WeatherWidgetProvider() { 
        // Start the worker thread 
        sWorkerThread = new HandlerThread("WeatherWidgetProvider-worker");
        sWorkerThread.start();
        sWorkerQueue = new Handler(sWorkerThread.getLooper());
    } 
 
    @Override 
    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);
Full Snippet Info
7
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE

Related Android HandlerThread Questions & Answers:

See Code Examples for Android HandlerThread Methods: