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:org.linkdroid.WebhookPostService.java

@Override
public void onCreate() {
    LogsService.logSystemDebugMessage(this, getString(R.string.webhook_post_service_creating));

    HandlerThread thread = new HandlerThread(TAG);
    thread.start();/*from  w  w w. ja  va2 s .  c o  m*/

    serviceLooper = thread.getLooper();
    serviceHandler = new ServiceHandler(serviceLooper);
}

From source file:ch.carteggio.provider.sync.NotificationService.java

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

    HandlerThread thread = new HandlerThread("NotificationService");
    thread.start();/*from ww w  .  j a  v  a2 s  .  co  m*/

    mServiceLooper = thread.getLooper();
    mServiceHandler = new ServiceHandler(mServiceLooper);

    mObserver = new Observer();

    getContentResolver().registerContentObserver(CarteggioContract.Messages.CONTENT_URI, true, mObserver);

}

From source file:autobahn.WampConnection.java

/**
 * Create the connection transmitting leg writer.
 *//*from   ww w.jav  a2s. c  om*/
protected void createWriter() {

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

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

From source file:org.projectbuendia.client.diagnostics.PackageServerHealthCheck.java

@Override
protected void startImpl() {
    synchronized (mLock) {
        if (mHandlerThread == null) {
            mHandlerThread = new HandlerThread("Buendia Package Server Health Check");
            mHandlerThread.start();// ww  w  . ja  v  a  2  s  . com
            mHandler = new Handler(mHandlerThread.getLooper());
            mHandler.post(mHealthCheckRunnable);
        }
    }
}

From source file:com.shizhefei.view.largeimage.ImageManager.java

public void start(OnImageLoadListenner invalidateListener) {
    this.onImageLoadListenner = invalidateListener;
    // // 1024??int
    final int maxMemory = (int) (Runtime.getRuntime().maxMemory() / 1024);
    // // Use 1/8th of the avaialable memory for this memory cache.
    // final int cacheSize = maxMemory / 8;
    Log.d("nnnn", "maxMemory :" + maxMemory);

    handlerThread = new HandlerThread("111");
    handlerThread.start();//from w w w. j av  a2  s.  c om
    handler = new LoadHandler(handlerThread.getLooper());
    LoadData loadData = mLoadData;
    if (loadData != null && loadData.mFactory != null) {
        load(loadData.mFactory);
    }
}

From source file:com.hmsoft.weargoproremote.services.WearMessageHandlerService.java

@Override
public void onCreate() {
    super.onCreate();
    if (Logger.DEBUG)
        Logger.debug(TAG, "Service created");

    HandlerThread executorThread = new HandlerThread("WearMessageHandlerService");
    executorThread.start();/*from   w  w w  .j  a v a2s.com*/
    mExecutorLooper = executorThread.getLooper();
    mWorkHandler = new Handler(mExecutorLooper, this);

    mPrefs = PreferenceManager.getDefaultSharedPreferences(this);
    mPass = mPrefs.getString(getString(R.string.preference_wifi_password_key), "");
    mPreviewEnabled = mPrefs.getBoolean(getString(R.string.preference_watch_preview_enabled_key), true);
    mGoProController = GoProController.getDefaultInstance(mPass);
    mPrefs.registerOnSharedPreferenceChangeListener(this);

    mSendStatusTimer = new Timer(60000, mWorkHandler, new Timer.TimerTask() {
        @Override
        public void onTick(int ticks) {
            sendCameraStatus();
            if (BuildConfig.DEBUG)
                Logger.debug(TAG, "Status sent...");
        }
    });

    updateNotification(getString(R.string.status_connection_starting));
}

From source file:com.snt.bt.recon.services.BcScanService.java

@Override
public int onStartCommand(Intent intent, int flags, int startId) {

    //leave cpu on
    wl = ((PowerManager) getSystemService(Context.POWER_SERVICE)).newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,
            "wlTag2");
    wl.acquire();/*from  w  w w. j av a 2  s .c  o  m*/

    HandlerThread handlerThread = new HandlerThread("ht");
    handlerThread.start();
    Looper looper = handlerThread.getLooper();
    handler = new Handler(looper);

    //show notification
    showNotification();

    if (intent != null) {
        final String action = intent.getAction();
        if (ACTION_START_SCAN.equals(action)) {
            //final String param1 = intent.getStringExtra(EXTRA_LAT);
            sessionId = UUID.fromString(intent.getStringExtra(EXTRA_SID));
            handleActionStartScan();

        }
    }
    return START_STICKY;
}

From source file:com.android.wfds.printservice.WPrintService.java

@Override
public void onCreate() {
    mJNI = new WprintJNI();
    mServiceHandler = new ServiceHandler(this);
    mServiceMessenger = new Messenger(mServiceHandler);
    WPrintService.loadLibraries(getApplicationInfo());
    super.onCreate();
    HandlerThread jobThread = new HandlerThread(MobilePrintConstants.PRINT_SERVICE_JOB_THREAD_ID);
    jobThread.start();/* ww  w . j  a  v  a 2s .  c  o  m*/
    mJobHandler = new JobHandler(this, jobThread.getLooper(), mJNI);
    mJobHandler.sendEmptyMessage(MobilePrintConstants.WPRINT_SERVICE_MSG__INIT);
}

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

public void init(Activity activity) {
    T.UI();//from   w w w .j  a v a 2 s . co  m
    mActivity = activity;
    mUIHandler = new Handler();
    T.setUIThread("RegistrationProcedureActivity.UI");

    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.WORKER");
        }
    });

    startRegistrationService();
}

From source file:com.grass.caishi.cc.service.BaseIntentService.java

/**
 * Creates an IntentService. Invoked by your subclass's constructor.
 * //from w w  w.j a  v a2 s . c  om
 * @param name
 *            Used to name the worker thread, important only for debugging.
 */
// public BaseIntentService(Context context){
// super(context);
// }

// public class BroadCastListen extends BroadcastReceiver{
// @Override
// public void onReceive(Context context, Intent intent) {
// // TODO Auto-generated method stub
// int ddo=intent.getIntExtra("do", 0);
// int fileid=intent.getIntExtra("imageId", 0);
// String str=intent.getAction();
// if(str.equals(broadcase)&&ddo==UP_DEL&&fileid!=0){
// mServiceHandler.removeMessages(fileid);
// for (int i = 0; i < filelist.size(); i++) {
// ImageItem fu=filelist.get(i);
// if(fu.imageId==fileid){
// filelist.remove(i);
// intent.putExtra("do", UP_DEL);
// sendBroadcast(intent);
// break;
// }
// }
// }
// }
// }

@Override
public void onCreate() {
    super.onCreate();
    // filelist.clear();
    intent = new Intent(BroadCastName);
    // broadcase=new BroadCastListen();
    // IntentFilter filter=new IntentFilter(BroadCastName);
    // registerReceiver(broadcase, filter);

    HandlerThread thread = new HandlerThread("IntentService[" + mName + "]");
    thread.start();

    mServiceLooper = thread.getLooper();
    mServiceHandler = new ServiceHandler(mServiceLooper);
}