use of android.os.HandlerThread in project zxing-android-embedded by journeyapps.
the class CameraThread method checkRunning.
private void checkRunning() {
synchronized (LOCK) {
if (this.handler == null) {
if (openCount <= 0) {
throw new IllegalStateException("CameraThread is not open");
}
this.thread = new HandlerThread("CameraThread");
this.thread.start();
this.handler = new Handler(thread.getLooper());
}
}
}
use of android.os.HandlerThread in project Klyph by jonathangerbaud.
the class FriendRequestService method onCreate.
@Override
public void onCreate() {
HandlerThread thread = new HandlerThread("ServiceStartArguments", android.os.Process.THREAD_PRIORITY_BACKGROUND);
thread.start();
mServiceLooper = thread.getLooper();
mServiceHandler = new ServiceHandler(mServiceLooper, new WeakReference<Service>(this));
}
use of android.os.HandlerThread in project Klyph by jonathangerbaud.
the class NotificationService method onCreate.
@Override
public void onCreate() {
// Why initialize device values ?
// Because we need the density to calculate image size
// In notification request
KlyphDevice.initDeviceValues(this);
HandlerThread thread = new HandlerThread("ServiceStartArguments", android.os.Process.THREAD_PRIORITY_BACKGROUND);
thread.start();
mServiceLooper = thread.getLooper();
mServiceHandler = new ServiceHandler(mServiceLooper, new WeakReference<Service>(this));
}
use of android.os.HandlerThread in project Klyph by jonathangerbaud.
the class UploadPhotoService method onCreate.
@Override
public void onCreate() {
HandlerThread thread = new HandlerThread("ServiceStartArguments", android.os.Process.THREAD_PRIORITY_BACKGROUND);
thread.start();
mServiceLooper = thread.getLooper();
mServiceHandler = new ServiceHandler(mServiceLooper, new WeakReference<Service>(this));
}
use of android.os.HandlerThread in project remusic by aa112901.
the class MediaService method onCreate.
@Override
public void onCreate() {
if (D)
Log.d(TAG, "Creating service");
super.onCreate();
mGetUrlThread.start();
mLrcThread.start();
mProxy = new MediaPlayerProxy(this);
mProxy.init();
mProxy.start();
mNotificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
// gets a pointer to the playback state store
mPlaybackStateStore = MusicPlaybackState.getInstance(this);
mSongPlayCount = SongPlayCount.getInstance(this);
mRecentStore = RecentStore.getInstance(this);
mHandlerThread = new HandlerThread("MusicPlayerHandler", android.os.Process.THREAD_PRIORITY_BACKGROUND);
mHandlerThread.start();
mPlayerHandler = new MusicPlayerHandler(this, mHandlerThread.getLooper());
mAudioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
mMediaButtonReceiverComponent = new ComponentName(getPackageName(), MediaButtonIntentReceiver.class.getName());
mAudioManager.registerMediaButtonEventReceiver(mMediaButtonReceiverComponent);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
setUpMediaSession();
}
mPreferences = getSharedPreferences("Service", 0);
mCardId = getCardId();
registerExternalStorageListener();
mPlayer = new MultiPlayer(this);
mPlayer.setHandler(mPlayerHandler);
// Initialize the intent filter and each action
final IntentFilter filter = new IntentFilter();
filter.addAction(SERVICECMD);
filter.addAction(TOGGLEPAUSE_ACTION);
filter.addAction(PAUSE_ACTION);
filter.addAction(STOP_ACTION);
filter.addAction(NEXT_ACTION);
filter.addAction(PREVIOUS_ACTION);
filter.addAction(PREVIOUS_FORCE_ACTION);
filter.addAction(REPEAT_ACTION);
filter.addAction(SHUFFLE_ACTION);
filter.addAction(TRY_GET_TRACKINFO);
filter.addAction(Intent.ACTION_SCREEN_OFF);
filter.addAction(LOCK_SCREEN);
filter.addAction(SEND_PROGRESS);
filter.addAction(SETQUEUE);
// Attach the broadcast listener
registerReceiver(mIntentReceiver, filter);
mMediaStoreObserver = new MediaStoreObserver(mPlayerHandler);
getContentResolver().registerContentObserver(MediaStore.Audio.Media.INTERNAL_CONTENT_URI, true, mMediaStoreObserver);
getContentResolver().registerContentObserver(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI, true, mMediaStoreObserver);
// Initialize the wake lock
final PowerManager powerManager = (PowerManager) getSystemService(Context.POWER_SERVICE);
mWakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, getClass().getName());
mWakeLock.setReferenceCounted(false);
final Intent shutdownIntent = new Intent(this, MediaService.class);
shutdownIntent.setAction(SHUTDOWN);
mAlarmManager = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
mShutdownIntent = PendingIntent.getService(this, 0, shutdownIntent, 0);
scheduleDelayedShutdown();
reloadQueueAfterPermissionCheck();
notifyChange(QUEUE_CHANGED);
notifyChange(META_CHANGED);
}
Aggregations