Search in sources :

Example 31 with HandlerThread

use of android.os.HandlerThread in project XobotOS by xamarin.

the class SipService method createLooper.

private static Looper createLooper() {
    HandlerThread thread = new HandlerThread("SipService.Executor");
    thread.start();
    return thread.getLooper();
}
Also used : HandlerThread(android.os.HandlerThread)

Example 32 with HandlerThread

use of android.os.HandlerThread in project platform_frameworks_base by android.

the class IntentService method onCreate.

@Override
public void onCreate() {
    // TODO: It would be nice to have an option to hold a partial wakelock
    // during processing, and to have a static startService(Context, Intent)
    // method that would launch the service & hand off a wakelock.
    super.onCreate();
    HandlerThread thread = new HandlerThread("IntentService[" + mName + "]");
    thread.start();
    mServiceLooper = thread.getLooper();
    mServiceHandler = new ServiceHandler(mServiceLooper);
}
Also used : HandlerThread(android.os.HandlerThread)

Example 33 with HandlerThread

use of android.os.HandlerThread in project platform_frameworks_base by android.

the class SeekBarVolumizer method start.

public void start() {
    // already started
    if (mHandler != null)
        return;
    HandlerThread thread = new HandlerThread(TAG + ".CallbackHandler");
    thread.start();
    mHandler = new Handler(thread.getLooper(), this);
    mHandler.sendEmptyMessage(MSG_INIT_SAMPLE);
    mVolumeObserver = new Observer(mHandler);
    mContext.getContentResolver().registerContentObserver(System.getUriFor(System.VOLUME_SETTINGS[mStreamType]), false, mVolumeObserver);
    mReceiver.setListening(true);
}
Also used : HandlerThread(android.os.HandlerThread) ContentObserver(android.database.ContentObserver) Handler(android.os.Handler)

Example 34 with HandlerThread

use of android.os.HandlerThread in project realm-java by realm.

the class RealmTests method closeRealmInChangeListener.

// Tests if close can be called from Realm change listener when there is no other listeners.
@Test
public void closeRealmInChangeListener() {
    realm.close();
    final CountDownLatch signalTestFinished = new CountDownLatch(1);
    HandlerThread handlerThread = new HandlerThread("background");
    handlerThread.start();
    final Handler handler = new Handler(handlerThread.getLooper());
    handler.post(new Runnable() {

        @Override
        public void run() {
            final Realm realm = Realm.getInstance(realmConfig);
            final RealmChangeListener<Realm> listener = new RealmChangeListener<Realm>() {

                @Override
                public void onChange(Realm object) {
                    if (realm.where(AllTypes.class).count() == 1) {
                        realm.removeChangeListener(this);
                        realm.close();
                        signalTestFinished.countDown();
                    }
                }
            };
            realm.addChangeListener(listener);
            realm.executeTransactionAsync(new Realm.Transaction() {

                @Override
                public void execute(Realm realm) {
                    realm.createObject(AllTypes.class);
                }
            });
        }
    });
    TestHelper.awaitOrFail(signalTestFinished);
}
Also used : HandlerThread(android.os.HandlerThread) Handler(android.os.Handler) AllTypes(io.realm.entities.AllTypes) CountDownLatch(java.util.concurrent.CountDownLatch) SharedRealm(io.realm.internal.SharedRealm) Test(org.junit.Test)

Example 35 with HandlerThread

use of android.os.HandlerThread in project robolectric by robolectric.

the class ShadowLooperTest method schedulerOnAnotherLooper_shouldNotBeMaster_byDefault.

@Test
public void schedulerOnAnotherLooper_shouldNotBeMaster_byDefault() {
    HandlerThread ht = getHandlerThread();
    assertThat(shadowOf(ht.getLooper()).getScheduler()).isNotSameAs(RuntimeEnvironment.getMasterScheduler());
}
Also used : HandlerThread(android.os.HandlerThread) Test(org.junit.Test)

Aggregations

HandlerThread (android.os.HandlerThread)313 Handler (android.os.Handler)149 IntentFilter (android.content.IntentFilter)34 Message (android.os.Message)26 PowerManager (android.os.PowerManager)26 Intent (android.content.Intent)25 Context (android.content.Context)22 Test (org.junit.Test)20 Runnable (java.lang.Runnable)15 ComponentName (android.content.ComponentName)14 View (android.view.View)14 Looper (android.os.Looper)13 PendingIntent (android.app.PendingIntent)12 MediumTest (android.test.suitebuilder.annotation.MediumTest)12 RemoteException (android.os.RemoteException)11 MediaFormat (android.media.MediaFormat)10 Uri (android.net.Uri)10 Pair (android.util.Pair)10 SmallTest (android.test.suitebuilder.annotation.SmallTest)9 Bundle (android.os.Bundle)8