Example usage for android.os HandlerThread HandlerThread

List of usage examples for android.os HandlerThread HandlerThread

Introduction

In this page you can find the example usage for android.os HandlerThread HandlerThread.

Prototype

public HandlerThread(String name) 

Source Link

Usage

From source file:com.mobicage.rogerthat.registration.ContentBrandingRegistrationActivity.java

private void createWorkerThread() {
    T.UI();/*from w  ww. ja  v a2s  . c o  m*/
    mWorkerThread = new HandlerThread("rogerthat_registration_worker");
    mWorkerThread.start();
    mWorkerLooper = mWorkerThread.getLooper();
    mWorkerHandler = new Handler(mWorkerLooper);
    mWorkerHandler.post(new SafeRunnable() {
        @Override
        public void safeRun() {
            T.setRegistrationThread("RegistrationProcedureActivity.createWorkerThread()");
        }
    });
}

From source file:com.irccloud.android.IRCCloudApplicationBase.java

private Handler getFontsHandler() {
    if (mFontsHandler == null) {
        HandlerThread handlerThread = new HandlerThread("fonts");
        handlerThread.start();//from w w w .j a v a  2  s.  co  m
        mFontsHandler = new Handler(handlerThread.getLooper());
    }
    return mFontsHandler;
}

From source file:com.magnet.mmx.client.MMXClient.java

private MMXClient(String name, Context context, MMXClientConfig config) {
    mName = name;/*from w ww . j av a2  s.  com*/
    mContext = context.getApplicationContext();
    mMMXContext = getMMXContext(mContext);
    mSharedPreferences = getSharedPrefs(context, name);
    mMessagingThread = new HandlerThread("MMXHandlerThread-" + name);
    mMessagingThread.start();
    mMessagingHandler = new Handler(mMessagingThread.getLooper());

    applyConfig(config);
    mConnection = new MMXConnection(mMMXContext, getQueue(), mSettings);
    mConnection.setMessageListener(mMessageListener);

    try {
        MessageDigest digester = MessageDigest.getInstance("SHA-256");
        String encryptionString = mEncryptionString + context.getPackageName() + mMMXContext.getDeviceId();
        digester.update(encryptionString.getBytes());
        mEncryptionKey = digester.digest();
        mEncryptor = new DefaultEncryptor(mEncryptionKey);
    } catch (Exception e) {
        Log.e(TAG, "MMXClient(): Unable to initialize encryptor.", e);
    }
}

From source file:com.google.android.apps.muzei.gallery.GallerySettingsActivity.java

private void runOnHandlerThread(Runnable runnable) {
    if (mHandlerThread == null) {
        mHandlerThread = new HandlerThread("GallerySettingsActivity");
        mHandlerThread.start();// w  ww .  ja  v a 2  s .  c o  m
        mHandler = new Handler(mHandlerThread.getLooper());
    }
    mHandler.post(runnable);
}

From source file:de.tubs.ibr.dtn.service.DaemonService.java

@Override
public void onCreate() {
    super.onCreate();

    // open statistic database
    mStatsDatabase = new StatsDatabase(this);
    mStatsLastAction = null;//ww w.j a va  2  s . c o  m

    // create daemon main thread
    mDaemonProcess = new DaemonProcess(this, mProcessHandler);

    /*
     * incoming Intents will be processed by ServiceHandler and queued in
     * HandlerThread
     */
    HandlerThread thread = new HandlerThread("DaemonService_IntentThread");
    thread.start();
    mServiceLooper = thread.getLooper();
    mServiceHandler = new ServiceHandler(mServiceLooper);

    // create a session manager
    mSessionManager = new SessionManager(this);

    // create P2P Manager
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
        mP2pManager = new P2pManager(this);
        mP2pManager.create();
    }

    // start initialization of the daemon process
    final Intent intent = new Intent(this, DaemonService.class);
    intent.setAction(de.tubs.ibr.dtn.service.DaemonService.ACTION_INITIALIZE);

    // queue the initialization job as the first job of the handler
    Message msg = mServiceHandler.obtainMessage();
    msg.arg1 = -1; // invalid startId (this never leads to a stop of the
                   // service)
    msg.obj = intent;
    mServiceHandler.sendMessage(msg);
}

From source file:com.bitants.wally.activities.ImageDetailsActivity.java

private void setupHandlers() {
    HandlerThread handlerThread = new HandlerThread("background");
    handlerThread.start();//from w ww  .j a v  a 2  s  . com
    backgroundHandler = new Handler(handlerThread.getLooper(), this);
    uiHandler = new Handler(getMainLooper(), this);
}

From source file:autobahn.WebSocketConnection.java

/**
 * Create WebSockets background writer./*  ww  w  .j  a va  2  s.com*/
 */
protected void createWriter() {

    mWriterThread = new HandlerThread("WebSocketWriter");
    mWriterThread.start();
    mWriter = new WebSocketWriter(mWriterThread.getLooper(), mMasterHandler, mTransportChannel, mOptions);

    if (DEBUG)
        Log.d(TAG, "WS writer created and started");
}

From source file:com.google.android.apps.watchme.StreamerActivity.java

private void startBackgroundThread() {
    backgroundHandlerThread = new HandlerThread("YT-WatchMe");
    backgroundHandlerThread.start();/*from www .  ja v  a2  s . co m*/
    backgroundHandler = new Handler(backgroundHandlerThread.getLooper());
}

From source file:com.oddrun.befrest.connectivity.WebSocketConnection.java

/**
 * Create WebSockets background writer.//from w  w w .  j a va  2s  .  c o m
 */
protected void createWriter() {
    mWriterThread = new HandlerThread("WebSocketWriter");
    mWriterThread.start();
    mWriter = new WebSocketWriter(mWriterThread.getLooper(), mMasterHandler, mTransportChannel, mOptions);

    if (DEBUG)
        Log.d(TAG, "WS writer created and started");
}

From source file:com.tzutalin.dlibtest.CameraConnectionFragment.java

/**
 * Starts a background thread and its {@link Handler}.
 *//*from   www .j  a  va  2s  .c  om*/
@DebugLog
private void startBackgroundThread() {
    backgroundThread = new HandlerThread("ImageListener");
    backgroundThread.start();
    backgroundHandler = new Handler(backgroundThread.getLooper());

    inferenceThread = new HandlerThread("InferenceThread");
    inferenceThread.start();
    inferenceHandler = new Handler(inferenceThread.getLooper());
}