Example usage for android.os HandlerThread getLooper

List of usage examples for android.os HandlerThread getLooper

Introduction

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

Prototype

public Looper getLooper() 

Source Link

Document

This method returns the Looper associated with this thread.

Usage

From source file:io.n7.calendar.caldav.CalDAVService.java

@Override
public void onCreate() {
    mCR = getContentResolver();//  w  w w.j av a  2s  .  c o m
    // Check if there are any CalDAV accounts setup.
    // Check if the CalDAV calendars are present in the provider DB. If not, create.
    // Start Sync for all CalDAV calendars.
    mContext = this;
    HandlerThread thread = new HandlerThread("CalDAVService", Process.THREAD_PRIORITY_BACKGROUND);
    thread.start();

    mServiceLooper = thread.getLooper();
    mServiceHandler = new IncomingHandler(mServiceLooper);
    mMessenger = new Messenger(mServiceHandler);

}

From source file:cz.muni.fi.japanesedictionary.parser.ParserService.java

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

    HandlerThread thread = new HandlerThread("IntentService[Dictionary_parser]");
    thread.start();/*from   w w  w. j  ava2  s. c  om*/

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

}

From source file:com.ubergeek42.WeechatAndroid.service.RelayServiceBackbone.java

@Override
public void onCreate() {
    if (DEBUG)/* ww w .  ja  v a2s  . com*/
        logger.debug("onCreate()");
    super.onCreate();

    prefs = PreferenceManager.getDefaultSharedPreferences(getBaseContext());
    prefs.registerOnSharedPreferenceChangeListener(this);
    notificationManger = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);

    // prepare handler that will run on a separate thread
    HandlerThread handler_thread = new HandlerThread("doge");
    handler_thread.start();
    thandler = new Handler(handler_thread.getLooper());

    startForeground(NOTIFICATION_ID, buildNotification(null, "Tap to connect", null));

    disconnected = false;
    already_had_intent = false;
    network_unavailable = false;

    // Prepare for dealing with SSL certs
    certmanager = new SSLHandler(new File(getDir("sslDir", Context.MODE_PRIVATE), "keystore.jks"));

    registerReceiver(connectivityActionReceiver, new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION));

    alarmMgr = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
}

From source file:com.wbtech.ums.UmsAgent.java

private UmsAgent() {
    HandlerThread localHandlerThread = new HandlerThread("UmsAgent");
    localHandlerThread.start();/* w ww  .java 2s.c o m*/
    this.handler = new Handler(localHandlerThread.getLooper());
}

From source file:me.piebridge.prevent.ui.PreventActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    ThemeUtils.setTheme(this);
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);//from w  ww .ja v  a 2 s  .co  m
    ThemeUtils.fixSmartBar(this);

    mPager = (ViewPager) findViewById(R.id.pager);
    main = findViewById(R.id.main);
    actions = findViewById(R.id.actions);
    removeButton = (Button) findViewById(R.id.remove);
    preventButton = (Button) findViewById(R.id.prevent);
    removeButton.setOnClickListener(this);
    preventButton.setOnClickListener(this);
    preventButton.setEnabled(false);
    removeButton.setEnabled(false);
    receiver = new HookReceiver();

    mPageTitles = new String[] { getString(R.string.applications), getString(R.string.prevent_list) };
    mPageSelections = new ArrayList<Set<String>>();
    mPageSelections.add(new HashSet<String>());
    mPageSelections.add(new HashSet<String>());
    mPager.setOnPageChangeListener(this);
    mPager.setAdapter(new ScreenSlidePagerAdapter(getSupportFragmentManager()));

    HandlerThread thread = new HandlerThread("PreventUI");
    thread.start();
    mHandler = new Handler(thread.getLooper());

    try {
        ActionBar actionBar = getActionBar();
        if (actionBar != null) {
            actions.setVisibility(View.GONE);
        }
    } catch (NoSuchMethodError e) { // NOSONAR
        // do nothing
    }

    try {
        Class<?> clazz = Class.forName("de.robv.android.xposed.XposedBridge", false,
                ClassLoader.getSystemClassLoader());
        Field field = clazz.getDeclaredField("disableHooks");
        field.setAccessible(true);
        field.set(null, true);
    } catch (ClassNotFoundException e) {
        UILog.d("cannot find Xposed", e);
    } catch (Throwable t) { // NOSONAR
        UILog.d("cannot disable Xposed", t);
    }

    if (!BuildConfig.RELEASE && TextUtils.isEmpty(LicenseUtils.getLicense(this))) {
        showTestDialog();
    } else {
        init();
    }
}

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;//from ww w . j a v a2s.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.owncloud.android.services.OperationsService.java

/**
 * Service initialization// ww  w  .ja  v  a  2  s .co  m
 */
@Override
public void onCreate() {
    super.onCreate();
    Log_OC.d(TAG, "Creating service");

    /// First worker thread for most of operations 
    HandlerThread thread = new HandlerThread("Operations thread", Process.THREAD_PRIORITY_BACKGROUND);
    thread.start();
    mOperationsHandler = new ServiceHandler(thread.getLooper(), this);
    mOperationsBinder = new OperationsServiceBinder(mOperationsHandler);

    /// Separated worker thread for download of folders (WIP)
    thread = new HandlerThread("Syncfolder thread", Process.THREAD_PRIORITY_BACKGROUND);
    thread.start();
    mSyncFolderHandler = new SyncFolderHandler(thread.getLooper(), this);

    // create manager for local broadcasts
    mLocalBroadcastManager = LocalBroadcastManager.getInstance(this);
}

From source file:com.bitants.wally.fragments.SearchFragment.java

private void setupHandlers() {
    HandlerThread handlerThread = new HandlerThread("Search.background");
    handlerThread.start();/*  w  w w .j a  va 2  s.  co m*/
    backgroundHandler = new Handler(handlerThread.getLooper(), this);
    uiHandler = new Handler(getActivity().getMainLooper(), this);
}

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();/*  w w  w  . j av  a 2  s. c  om*/
    mJobHandler = new JobHandler(this, jobThread.getLooper(), mJNI);
    mJobHandler.sendEmptyMessage(MobilePrintConstants.WPRINT_SERVICE_MSG__INIT);
}

From source file:mobisocial.musubi.service.AddressBookUpdateHandler.java

public AddressBookUpdateHandler(Context context, SQLiteOpenHelper dbh, HandlerThread thread,
        ContentResolver resolver) {//from  w  ww  .j  a  v a  2  s  .  com
    super(new Handler(thread.getLooper()));
    mThread = thread;
    mContext = context.getApplicationContext();
    mContactThumbnailCache = App.getContactCache(context);
    mAccountType = mContext.getString(R.string.account_type);

    resolver.registerContentObserver(MusubiService.FORCE_RESCAN_CONTACTS, false,
            new ContentObserver(new Handler(thread.getLooper())) {
                public void onChange(boolean selfChange) {
                    mLastRun = -1;
                    AddressBookUpdateHandler.this.dispatchChange(false);
                }
            });

    dispatchChange(false);
}