Java Code Examples for android.os.HandlerThread#getLooper()
The following examples show how to use
android.os.HandlerThread#getLooper() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DownloadManager.java From Telegram-FOSS with GNU General Public License v2.0 | 6 votes |
public InternalHandler( HandlerThread thread, WritableDownloadIndex downloadIndex, DownloaderFactory downloaderFactory, Handler mainHandler, int maxParallelDownloads, int minRetryCount, boolean downloadsPaused) { super(thread.getLooper()); this.thread = thread; this.downloadIndex = downloadIndex; this.downloaderFactory = downloaderFactory; this.mainHandler = mainHandler; this.maxParallelDownloads = maxParallelDownloads; this.minRetryCount = minRetryCount; this.downloadsPaused = downloadsPaused; downloads = new ArrayList<>(); activeTasks = new HashMap<>(); }
Example 2
Source File: ThreadPool.java From IPCInvoker with Apache License 2.0 | 6 votes |
private Handler createHandler() { final HandlerThread handlerThread = new HandlerThread("ThreadPool#WorkerThread-" + hashCode()) { @Override protected void onLooperPrepared() { Log.i(TAG, "createHandler(id : %d), onLooperPrepared", getThreadId()); } }; handlerThread.start(); Handler handler = new Handler(handlerThread.getLooper()); handler.post(new Runnable() { @Override public void run() { Log.i(TAG, "createHandler(id : %d)", handlerThread.getThreadId()); } }); return handler; }
Example 3
Source File: CTABTestController.java From clevertap-android-sdk with MIT License | 6 votes |
public CTABTestController(Context context, CleverTapInstanceConfig config, String guid, CTABTestListener listener) { this.varCache = new CTVarCache(); this.enableEditor = config.isUIEditorEnabled(); this.config = config; this.guid = guid; this.setListener(listener); this.uiEditor = new UIEditor(context, config); final HandlerThread thread = new HandlerThread(CTABTestController.class.getCanonicalName()); thread.setPriority(Process.THREAD_PRIORITY_BACKGROUND); thread.start(); executionThreadHandler = new ExecutionThreadHandler(context, config, thread.getLooper()); executionThreadHandler.start(); if (enableEditor) { final Application app = (Application) context.getApplicationContext(); app.registerActivityLifecycleCallbacks(new LifecycleCallbacks()); } else { config.getLogger().debug(config.getAccountId(), "UIEditor connection is disabled"); } applyStoredExperiments(); }
Example 4
Source File: CameraImplV2.java From habpanelviewer with GNU General Public License v3.0 | 5 votes |
CameraImplV2(Activity context, TextureView prevView, boolean cameraFallback) throws CameraException { super(context, prevView); mCamManager = (CameraManager) mActivity.getSystemService(Context.CAMERA_SERVICE); if (mCamManager == null) { throw new CameraException(mActivity.getString(R.string.couldNotObtainCameraService)); } try { findCameraFacing(CameraCharacteristics.LENS_FACING_FRONT); if (mCameraId == null && cameraFallback) { findCameraFacing(CameraCharacteristics.LENS_FACING_BACK); } } catch (CameraAccessException e) { throw new CameraException(e); } if (mCameraId == null) { if (cameraFallback) { throw new CameraException(mActivity.getString(R.string.cameraMissing)); } else { throw new CameraException(mActivity.getString(R.string.frontCameraMissing)); } } mPreviewThread = new HandlerThread("previewThread"); mPreviewThread.start(); mPreviewHandler = new Handler(mPreviewThread.getLooper()); }
Example 5
Source File: BulkDownloadFragment.java From edx-app-android with Apache License 2.0 | 5 votes |
@Override public void onViewCreated(View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); prefManager = new VideoPrefs(getContext()); permissionListener = this; final HandlerThread handlerThread = new HandlerThread("BulkDownloadBgThread"); handlerThread.start(); bgThreadHandler = new Handler(handlerThread.getLooper()); ViewCompat.setImportantForAccessibility(binding.getRoot(), ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_NO); ViewCompat.setImportantForAccessibility(binding.ivIcon, ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_NO); ViewCompat.setImportantForAccessibility(binding.tvTitle, ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_NO); ViewCompat.setImportantForAccessibility(binding.tvSubtitle, ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_NO); ViewCompat.setImportantForAccessibility(binding.pbDownload, ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_NO); ViewCompat.setImportantForAccessibility(binding.swDownload, ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_YES); initDownloadSwitch(); if (totalDownloadableVideos != null && videosStatus.courseComponentId != null) { populateViewHolder(downloadListener, videosStatus.courseComponentId, totalDownloadableVideos); } if (bulkDownloadWasCancelled) { onEvent(new BulkVideosDownloadCancelledEvent()); bulkDownloadWasCancelled = false; } if (bulkDownloadWasStarted) { onEvent(new BulkVideosDownloadStartedEvent()); bulkDownloadWasStarted = false; } }
Example 6
Source File: BaseCameraActivity.java From fritz-examples with MIT License | 5 votes |
@Override public synchronized void onResume() { Log.d(TAG, "onResume " + this); super.onResume(); handlerThread = new HandlerThread("inference"); handlerThread.start(); handler = new Handler(handlerThread.getLooper()); }
Example 7
Source File: FriendRequestService.java From Klyph with MIT License | 5 votes |
@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)); }
Example 8
Source File: NetworkServerService.java From FireFiles with Apache License 2.0 | 5 votes |
@Override public void onCreate() { HandlerThread thread = new HandlerThread( "ServiceStartArguments", Process.THREAD_PRIORITY_BACKGROUND); thread.start(); serviceLooper = thread.getLooper(); serviceHandler = createServiceHandler(serviceLooper, this); }
Example 9
Source File: SpeakEasyService.java From android-test with Apache License 2.0 | 5 votes |
@Override public void onCreate() { super.onCreate(); HandlerThread backgroundThread = new HandlerThread("SpeakEasyService"); backgroundThread.start(); backgroundLooper = backgroundThread.getLooper(); backgroundHandler = new Handler(backgroundLooper) { @Override public void handleMessage(Message m) { serveIntent((Intent) m.obj, m.arg1); } }; }
Example 10
Source File: CameraConnectionFragment.java From AndroidDemoProjects with Apache License 2.0 | 5 votes |
/** * Starts a background thread and its {@link Handler}. */ private void startBackgroundThread() { backgroundThread = new HandlerThread("ImageListener"); backgroundThread.start(); backgroundHandler = new Handler(backgroundThread.getLooper()); inferenceThread = new HandlerThread("InferenceThread"); inferenceThread.start(); inferenceHandler = new Handler(inferenceThread.getLooper()); }
Example 11
Source File: Ringer.java From CSipSimple with GNU General Public License v3.0 | 5 votes |
public Ringer(Context aContext) { context = aContext; vibrator = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE); ringerThread = new HandlerThread("RingerThread"); ringerThread.start(); ringerWorker = new RingWorkerHandler(ringerThread.getLooper()); }
Example 12
Source File: LetvIntentService.java From letv with Apache License 2.0 | 5 votes |
public void onCreate() { super.onCreate(); DebugLog.log(TAG, "=======================================Servcie onCreate!"); HandlerThread thread = new HandlerThread("IntentService[" + this.mName + "]"); thread.start(); this.mServiceLooper = thread.getLooper(); this.mServiceHandler = new ServiceHandler(this.mServiceLooper); }
Example 13
Source File: CameraActivity.java From tensorflow-classifier-android with Apache License 2.0 | 5 votes |
@Override public synchronized void onResume() { LOGGER.d("onResume " + this); super.onResume(); handlerThread = new HandlerThread("inference"); handlerThread.start(); handler = new Handler(handlerThread.getLooper()); }
Example 14
Source File: DiscoveryManager.java From zephyr with MIT License | 5 votes |
public DiscoveryManager(@NonNull Gson gson, @NonNull ILogger logger, @NonNull IPreferenceManager preferenceManager) { mGson = gson; mLogger = logger; mPreferenceManager = preferenceManager; HandlerThread mPacketHandlerThread = new HandlerThread(LOG_TAG); mPacketHandlerThread.start(); mPacketHandler = new Handler(mPacketHandlerThread.getLooper()); mDiscoveryRunnable = getDiscoveryRunnable(); mDiscoveredServers = new ArrayMap<>(); mDiscoveredServersLiveData = new MutableLiveData<>(); }
Example 15
Source File: VideoMediaPlayer.java From TigerVideo with Apache License 2.0 | 5 votes |
public VideoMediaPlayer() { mMediaPlayer = new MediaPlayer(); mMediaHandlerThread = new HandlerThread(TAG); mMediaHandlerThread.start(); mMediaHandler = new MediaHandler(mMediaHandlerThread.getLooper()); }
Example 16
Source File: CameraConnectionFragment.java From tensorflow-classifier-android with Apache License 2.0 | 4 votes |
/** * Starts a background thread and its {@link Handler}. */ private void startBackgroundThread() { backgroundThread = new HandlerThread("ImageListener"); backgroundThread.start(); backgroundHandler = new Handler(backgroundThread.getLooper()); }
Example 17
Source File: BackgroundTaskManager.java From injor with Apache License 2.0 | 4 votes |
private BackgroundTaskManager() { HandlerThread handlerThread = new HandlerThread("BackgroundTaskManager"); handlerThread.start(); backgroundHandler = new BackgroundHandler(handlerThread.getLooper()); }
Example 18
Source File: CameraConnectionFragment.java From fritz-examples with MIT License | 4 votes |
/** * Starts a background thread and its {@link Handler}. */ private void startBackgroundThread() { backgroundThread = new HandlerThread("ImageListener"); backgroundThread.start(); backgroundHandler = new Handler(backgroundThread.getLooper()); }
Example 19
Source File: Camera2BasicFragment.java From Android-Camera2-Front-with-Face-Detection with Apache License 2.0 | 4 votes |
/** * Starts a background thread and its {@link Handler}. */ private void startBackgroundThread() { mBackgroundThread = new HandlerThread("CameraBackground"); mBackgroundThread.start(); mBackgroundHandler = new Handler(mBackgroundThread.getLooper()); }
Example 20
Source File: HandlerThreadFactory.java From AndroidPerformanceMonitor with Apache License 2.0 | 4 votes |
public HandlerThreadWrapper(String threadName) { HandlerThread handlerThread = new HandlerThread("BlockCanary-" + threadName); handlerThread.start(); handler = new Handler(handlerThread.getLooper()); }