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();
}
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);
}
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);
}
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);
}
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());
}
Aggregations