public WebRTCModule(ReactApplicationContext reactContext) { super(reactContext); imageProcessingThread = new HandlerThread("PictureProcessing"); imageProcessingThread.start(); imagePorcessingHandler = new Handler(imageProcessingThread.getLooper()); mPeerConnectionObservers = new SparseArray<PeerConnectionObserver>(); mMediaStreams = new HashMap<String, MediaStream>(); mMediaStreamTracks = new HashMap<String, MediaStreamTrack>(); mVideoCapturers = new HashMap<String, VideoCapturer>(); mCameras = new HashMap<>(); pcConstraints.mandatory.add(new MediaConstraints.KeyValuePair("OfferToReceiveAudio", "true")); pcConstraints.mandatory.add(new MediaConstraints.KeyValuePair("OfferToReceiveVideo", "true")); pcConstraints.optional.add(new MediaConstraints.KeyValuePair("DtlsSrtpKeyAgreement", "true")); PeerConnectionFactory.initializeAndroidGlobals(reactContext, true, true, true); mFactory = new PeerConnectionFactory(); }
private void stopDraw() { DrawHandler handler = this.handler; this.handler = null; unlockCanvasAndPost(); if (handler != null) { handler.quit(); } if (this.mHandlerThread != null) { HandlerThread handlerThread = this.mHandlerThread; this.mHandlerThread = null; try { handlerThread.join(); } catch (InterruptedException e) { e.printStackTrace(); } handlerThread.quit(); } }
private void init() { if (isAndroidThingsDevice(this)) { initPIO(); } mBackgroundThread = new HandlerThread("BackgroundThread"); mBackgroundThread.start(); mBackgroundHandler = new Handler(mBackgroundThread.getLooper()); mBackgroundHandler.post(mInitializeOnBackground); // Let the user touch the screen to take a photo findViewById(R.id.container).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (mReady.get()) { Log.i(TAG, "Taking photo"); setReady(false); mBackgroundHandler.post(mBackgroundClickHandler); } else { Log.i(TAG, "Sorry, processing hasn't finished. Try again in a few seconds"); } } }); }
private void stopDraw() { if (this.handler != null) { this.handler.quit(); this.handler = null; } if (this.mHandlerThread != null) { HandlerThread handlerThread = this.mHandlerThread; this.mHandlerThread = null; try { handlerThread.join(); } catch (InterruptedException e) { e.printStackTrace(); } handlerThread.quit(); } }
@Override public void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); vibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE); setContentView(R.layout.scan_activity); scannerView = (ScannerView) findViewById(R.id.scan_activity_mask); previewView = (TextureView) findViewById(R.id.scan_activity_preview); previewView.setSurfaceTextureListener(this); cameraThread = new HandlerThread("cameraThread", Process.THREAD_PRIORITY_BACKGROUND); cameraThread.start(); cameraHandler = new Handler(cameraThread.getLooper()); if (ContextCompat.checkSelfPermission(this, Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED) ActivityCompat.requestPermissions(this, new String[] { Manifest.permission.CAMERA }, 0); }
@Override public void onCreate() { super.onCreate(); mHandlerThread = new HandlerThread(getClass().getSimpleName()); mHandlerThread.start(); mDbHandler = new Handler(mHandlerThread.getLooper()); mCaptioningManager = (CaptioningManager) getSystemService(Context.CAPTIONING_SERVICE); setTheme(android.R.style.Theme_Holo_Light_NoActionBar); mSessions = new ArrayList<>(); IntentFilter intentFilter = new IntentFilter(); intentFilter.addAction(TvInputManager.ACTION_BLOCKED_RATINGS_CHANGED); intentFilter.addAction(TvInputManager.ACTION_PARENTAL_CONTROLS_ENABLED_CHANGED); registerReceiver(mParentalControlsBroadcastReceiver, intentFilter); }
/** * Starts a background thread and its {@link Handler}. */ private void startBackgroundThread() { mBackgroundThread = new HandlerThread("CameraBackground"); mBackgroundThread.start(); mBackgroundHandler = new Handler(mBackgroundThread.getLooper()) { @Override public void handleMessage(Message msg) { super.handleMessage(msg); switch (msg.what) { case MSG_CAPTURE_PICTURE_WHEN_FOCUS_TIMEOUT: mState = STATE_PICTURE_TAKEN; captureStillPicture(); break; default: break; } } }; }
public a(int i, boolean z, h hVar, b bVar) { super(i, z, hVar); this.i = false; a(bVar); this.e = new g(); this.f = new g(); this.g = this.e; this.h = this.f; this.d = new char[bVar.f()]; bVar.b(); g(); this.j = new HandlerThread(bVar.c(), bVar.h()); if (this.j != null) { this.j.start(); } if (this.j.isAlive() && this.j.getLooper() != null) { this.k = new Handler(this.j.getLooper(), this); } }
public void open() { try { CameraManager manager = (CameraManager) mActivity.getSystemService(Context.CAMERA_SERVICE); for (String cameraId : manager.getCameraIdList()) { CameraCharacteristics characteristics = manager.getCameraCharacteristics(cameraId); if (characteristics.get(CameraCharacteristics.LENS_FACING) == CameraCharacteristics.LENS_FACING_BACK) { StreamConfigurationMap map = characteristics.get(CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP); mCameraSize = map.getOutputSizes(SurfaceTexture.class)[0]; HandlerThread thread = new HandlerThread("OpenCamera"); thread.start(); Handler backgroundHandler = new Handler(thread.getLooper()); manager.openCamera(cameraId, mCameraDeviceCallback, null); // カメラの物理的な情報を得る mCameraCharacteristics = manager.getCameraCharacteristics( cameraId ); return; } } } catch (CameraAccessException e) { e.printStackTrace(); } }
/** * Public constructor. * * @param triggerPin Name of the trigger pin * @param echoPin Name of the echo pin * @param listener {@link DistanceListener} to get callbacks when distance changes. */ public UltrasonicSensorDriver(@NonNull String triggerPin, @NonNull String echoPin, DistanceListener listener) { PeripheralManagerService service = new PeripheralManagerService(); try { setTriggerPin(service, triggerPin); setEchoPin(service, echoPin); } catch (IOException e) { e.printStackTrace(); throw new IllegalArgumentException("Invalid pin name."); } //Set callback listener. mListener = listener; if (mListener == null) throw new IllegalArgumentException("DistanceListener cannot be null."); //Start sending pulses //We are using different thread for sending pulses to increase time accuracy. HandlerThread triggerHandlerThread = new HandlerThread("TriggerHandlerThread"); triggerHandlerThread.start(); mTriggerHandler = new Handler(triggerHandlerThread.getLooper()); mTriggerHandler.post(mTriggerRunnable); }
@Override public void onCreate() { // Start up the thread running the service. Note that we create a // separate thread because the service normally runs in the process's // main thread, which we don't want to block. We also make it // background priority so CPU-intensive work will not disrupt our UI. HandlerThread thread = new HandlerThread("ServiceStartArguments", Process.THREAD_PRIORITY_BACKGROUND); thread.start(); mNotificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); mNotificationMap = new SparseIntArray(); // Get the HandlerThread's Looper and use it for our Handler mServiceLooper = thread.getLooper(); //mServiceHandler = new ServiceHandler(mServiceLooper); mServiceHandler = new ServiceHandler(mServiceLooper, this); setPrefs(PreferenceManager.getDefaultSharedPreferences(this)); }
protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); this.zcps = getSharedPreferences("reg", 0); setContentView(R.layout.activity_main); findView(); this.shouquanqqTextView.setText("正版注册授权QQ:" + getString(R.string.zhuceqq)); getPrefparas(); showPrefparas(); startService(new Intent(this, PhoneService.class)); this.startLayout.setVisibility(View.VISIBLE); new HandlerThread("myHandlerThread").start(); this.handler = new Handler() { public void handleMessage(Message msg) { if (msg.what == 0) { MainActivity.this.startLayout.setVisibility(View.INVISIBLE); MainActivity.this.gonggaoLayout.setVisibility(View.VISIBLE); MainActivity.this.mainlLayout.setVisibility(View.INVISIBLE); } } }; this.tt.run(); }
private d() { try { HandlerThread handlerThread = new HandlerThread("StatDispatcher"); handlerThread.start(); d = handlerThread.getId(); this.b = new Handler(handlerThread.getLooper()); HttpParams basicHttpParams = new BasicHttpParams(); HttpConnectionParams.setConnectionTimeout(basicHttpParams, 10000); HttpConnectionParams.setSoTimeout(basicHttpParams, 10000); this.a = new DefaultHttpClient(basicHttpParams); this.a.setKeepAliveStrategy(new e(this)); if (StatConfig.b() != null) { this.a.getParams().setParameter("http.route.default-proxy", StatConfig.b()); } } catch (Object th) { c.e(th); } }
public LCIMLocalStorage(Context context, String clientId, String tableName) { super(context, DB_NAME_PREFIX, null, DB_VERSION); if (TextUtils.isEmpty(tableName)) { throw new IllegalArgumentException("tableName can not be null"); } if (TextUtils.isEmpty(clientId)) { throw new IllegalArgumentException("clientId can not be null"); } final String md5ClientId = AVUtils.md5(clientId); this.tableName = tableName + "_" + md5ClientId; createTable(); readDbThread = new HandlerThread("LCIMLocalStorageReadThread"); readDbThread.start(); readDbHandler = new Handler(readDbThread.getLooper()); }
@Override public void onCreate() { super.onCreate(); log("onCreate"); // First init the Client Application application = getApplication(); if (application instanceof OSCApplication) { OSCApplication.reInit(); } HandlerThread thread = new HandlerThread(TweetPublishService.class.getSimpleName()); thread.start(); mServiceLooper = thread.getLooper(); mServiceHandler = new ServiceHandler(mServiceLooper); mReceiver = ListenAccountChangeReceiver.start(this); }
@Override public void onCreate() { Log.e(TAG, "onCreate"); super.onCreate(); mContext = getApplicationContext(); HandlerThread handlerThread = new HandlerThread("content_observer"); handlerThread.start(); final Handler handler = new Handler(handlerThread.getLooper()) { @Override public void handleMessage(Message msg) { super.handleMessage(msg); } }; mContentObserver = new ScreenShotContentObserver(handler, getContentResolver(), this); }
/** * Initializes the service when it is first created */ @Override public void onCreate() { super.onCreate(); if (Constants.LOGVV) { Log.v(Constants.TAG, "Service onCreate"); } mAlarmManager = (AlarmManager) getSystemService(Context.ALARM_SERVICE); mUpdateThread = new HandlerThread(TAG + "-UpdateThread"); mUpdateThread.start(); mUpdateHandler = new Handler(mUpdateThread.getLooper(), mUpdateCallback); mNotifier = new DownloadNotifier(this); mNotifier.cancelAll(); mObserver = new DownloadManagerContentObserver(); getContentResolver().registerContentObserver(Downloads.Impl.ALL_DOWNLOADS_CONTENT_URI, true, mObserver); }
private void stopDraw() { if (handler != null) { handler.quit(); handler = null; } if (mHandlerThread != null) { HandlerThread handlerThread = this.mHandlerThread; mHandlerThread = null; try { handlerThread.join(); } catch (InterruptedException e) { e.printStackTrace(); } handlerThread.quit(); } }
private void stopDraw() { DrawHandler handler = this.handler; this.handler = null; unlockCanvasAndPost(); if (handler != null) { handler.quit(); } if (mHandlerThread != null) { HandlerThread handlerThread = this.mHandlerThread; mHandlerThread = null; try { handlerThread.join(); } catch (InterruptedException e) { e.printStackTrace(); } handlerThread.quit(); } }
private void initUIHandlerAndThread() { mUIHandlerThread = new HandlerThread("ziggs_socket_UItransimit_thread"); mUIHandlerThread.start(); mHandler = new Handler(Looper.getMainLooper()) {//主线程handler @Override public void handleMessage(Message msg) { super.handleMessage(msg); switch (msg.what) { case MSG_RECEIVE_DATA: mObservable.setData(currentReceiveByteData, receivePacket.getAddress(), receivePacket.getPort()); break; case MSG_RECEIVE_TIMEOUT: mObservable.setData(UdpConfigs.TimeOut_Str.getBytes(), null, 0); break; } } }; }
private g() { if (this.f == null) { this.f = new HandlerThread("opensdk.report.handlerthread", 10); this.f.start(); } if (this.f.isAlive() && this.f.getLooper() != null) { this.g = new Handler(this, this.f.getLooper()) { final /* synthetic */ g a; public void handleMessage(Message message) { switch (message.what) { case 1000: this.a.b(); break; case 1001: this.a.e(); break; } super.handleMessage(message); } }; } }
/** * Construct a new SurfaceTextureHelper sharing OpenGL resources with |sharedContext|. A dedicated * thread and handler is created for handling the SurfaceTexture. May return null if EGL fails to * initialize a pixel buffer surface and make it current. */ public static SurfaceTextureHelper create( final String threadName, final EglBase.Context sharedContext) { final HandlerThread thread = new HandlerThread(threadName); thread.start(); final Handler handler = new Handler(thread.getLooper()); // The onFrameAvailable() callback will be executed on the SurfaceTexture ctor thread. See: // http://grepcode.com/file/repository.grepcode.com/java/ext/com.google.android/android/5.1.1_r1/android/graphics/SurfaceTexture.java#195. // Therefore, in order to control the callback thread on API lvl < 21, the SurfaceTextureHelper // is constructed on the |handler| thread. return ThreadUtils.invokeAtFrontUninterruptibly(handler, new Callable<SurfaceTextureHelper>() { @Override public SurfaceTextureHelper call() { try { return new SurfaceTextureHelper(sharedContext, handler); } catch (RuntimeException e) { Logging.e(TAG, threadName + " create failure", e); return null; } } }); }
@Override public void onCreate() { Log.d(TAG, "onCreate"); super.onCreate(); initializeIfNeeded(); HandlerThread thread = new HandlerThread("CloudPublisherService"); thread.start(); mServiceLooper = thread.getLooper(); mServiceHandler = new Handler(mServiceLooper); mServiceHandler.postDelayed(mSensorConsumerRunnable, PUBLISH_INTERVAL_MS); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); recyclerView = (RecyclerView) findViewById(R.id.recyclerview1); RecyclerView.LayoutManager layoutManager = new LinearLayoutManager(getApplicationContext()); recyclerView.setLayoutManager(layoutManager); recyclerViewAdapter = new RecyclerViewAdapter(pokemonList); recyclerView.setAdapter(recyclerViewAdapter); // Create a new handlerThread handlerThread = new HandlerThread("MyHandler"); handlerThread.start(); //Attached a handler handler = new Handler(Looper.getMainLooper()) { @Override public void handleMessage(Message msg) { Bundle bundle = msg.getData(); String message = bundle.getString("message"); pokemonList.add(message) ; recyclerViewAdapter.notifyDataSetChanged(); Log.d("message", "" + message); } }; final Button button = (Button) findViewById(R.id.pokemonButton); button.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { sendNewMessage(); } }); }
private void startBackgroundThread() { Log.i(LOGTAG, "startBackgroundThread"); stopBackgroundThread(); mBackgroundThread = new HandlerThread("CameraBackground"); mBackgroundThread.start(); mBackgroundHandler = new Handler(mBackgroundThread.getLooper()); }
@Override public boolean startQueueSerial(FileDownloadListener listener) { final SerialHandlerCallback callback = new SerialHandlerCallback(); final int attachKey = callback.hashCode(); final List<BaseDownloadTask.IRunningTask> list = FileDownloadList.getImpl(). assembleTasksToStart(attachKey, listener); if (onAssembledTasksToStart(attachKey, list, listener, true)) { return false; } final HandlerThread serialThread = new HandlerThread( FileDownloadUtils.formatString("filedownloader serial thread %s-%d", listener, attachKey)); serialThread.start(); final Handler serialHandler = new Handler(serialThread.getLooper(), callback); callback.setHandler(serialHandler); callback.setList(list); callback.goNext(0); synchronized (mRunningSerialMap) { mRunningSerialMap.put(attachKey, serialHandler); } return true; }
public NotificationCountStorage(String path) { mPath = path; mHandlerThread = new HandlerThread("NotificationCountStorage Thread"); mHandlerThread.start(); mHandler = new Handler(mHandlerThread.getLooper()); mHandler.post(this::open); }
private Api() { HandlerThread bgThread = new HandlerThread("api_thread"); bgThread.start(); bgHandler = new Handler(bgThread.getLooper()); mainHandler = new Handler(Looper.getMainLooper()); // Do nothing. }
@Override public void onCreate() { HandlerThread thread = new HandlerThread(TAG, Process.THREAD_PRIORITY_BACKGROUND); thread.start(); mServiceLooper = thread.getLooper(); mServiceHandler = new ServiceHandler(mServiceLooper); mSmsManager = SmsManager.getDefault(); }
private IPCBridgeManager() { mServiceClassMap = new HashMap<>(); mBridgeMap = new ConcurrentHashMap<>(); // HandlerThread thread = new HandlerThread("IPCBridgeThread#" + hashCode()); thread.start(); mHandler = new Handler(thread.getLooper()); }
@DebugLog 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()); CameraUtils.setBackgroundHandler(backgroundHandler); }
public HwAvcEncoder(final VideoConfig videoConfig, final MediaCodecCallback... callbacks) { mVideoConfig = videoConfig; mMediaCodecThread = new HandlerThread("HwAvcEncoderThread"); mMediaCodecThread.start(); mMediaCodecHandler = new Handler(mMediaCodecThread.getLooper()); mVideoEncoder = new MediaCodecVideoEncoder(); mMediaCodecCallbacks = Arrays.asList(callbacks); }
/** * Starts (enqueues) a stop routine in a new thread, then returns immediately. */ public void stopScanner() { HandlerThread ht = new HandlerThread("stopper"); ht.start(); cleanHandler = new Handler(ht.getLooper()); cleanHandler.post(new Runnable() { @Override public void run() { cleanup(); } }); ht.quitSafely(); }
/** * Starts a background thread and its {@link Handler}. */ public void startBackgroundThread() { mBackgroundThread = new HandlerThread("CameraBackground"); mBackgroundThread.start(); mBackgroundHandler = new Handler(mBackgroundThread.getLooper()); mBackgroundHandler.postDelayed(fragment.getScanningTakingLongTimeout(), (long) (SECONDS_TILL_SCAN_TIMEOUT * 1000)); }
@Override public void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); setRetainInstance(true); setHasOptionsMenu(true); bluetoothAdapter = BluetoothAdapter.getDefaultAdapter(); backgroundThread = new HandlerThread("backgroundThread", Process.THREAD_PRIORITY_BACKGROUND); backgroundThread.start(); backgroundHandler = new Handler(backgroundThread.getLooper()); if (savedInstanceState != null) { restoreInstanceState(savedInstanceState); } else { final Intent intent = activity.getIntent(); final String action = intent.getAction(); final Uri intentUri = intent.getData(); final String scheme = intentUri != null ? intentUri.getScheme() : null; final String mimeType = intent.getType(); if ((Intent.ACTION_VIEW.equals(action) || NfcAdapter.ACTION_NDEF_DISCOVERED.equals(action)) && intentUri != null && "bitcoin".equals(scheme)) { initStateFromBitcoinUri(intentUri); } else if ((NfcAdapter.ACTION_NDEF_DISCOVERED.equals(action)) && PaymentProtocol.MIMETYPE_PAYMENTREQUEST.equals(mimeType)) { final NdefMessage ndefMessage = (NdefMessage) intent .getParcelableArrayExtra(NfcAdapter.EXTRA_NDEF_MESSAGES)[0]; final byte[] ndefMessagePayload = Nfc.extractMimePayload(PaymentProtocol.MIMETYPE_PAYMENTREQUEST, ndefMessage); initStateFromPaymentRequest(mimeType, ndefMessagePayload); } else if ((Intent.ACTION_VIEW.equals(action)) && PaymentProtocol.MIMETYPE_PAYMENTREQUEST.equals(mimeType)) { final byte[] paymentRequest = BitcoinIntegration.paymentRequestFromIntent(intent); if (intentUri != null) initStateFromIntentUri(mimeType, intentUri); else if (paymentRequest != null) initStateFromPaymentRequest(mimeType, paymentRequest); else throw new IllegalArgumentException(); } else if (intent.hasExtra(SendCoinsActivity.INTENT_EXTRA_PAYMENT_INTENT)) { initStateFromIntentExtras(intent.getExtras()); } else { updateStateFrom(PaymentIntent.blank()); } } }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mLoaderThread = new HandlerThread("wallpaper_loader"); mLoaderThread.start(); mLoaderHandler = new Handler(mLoaderThread.getLooper(), this); init(); }
private static <T extends RealmObject> Observable<RealmResults<T>> listenRealmResults( final Func1<Realm, RealmResults<T>> query, AtomicReference<Realm> realmReference) { final HandlerThread dbHandler = createDbHandler(); final Scheduler scheduler = AndroidSchedulers.from(dbHandler.getLooper()); return Observable.defer(() -> { final Realm realm = Realm.getDefaultInstance(); realmReference.set(realm); return query.call(realm).asObservable(); }) .filter(result -> result.isLoaded() && result.isValid()) .subscribeOn(scheduler) .unsubscribeOn(scheduler); }
private void starts(){ stops(); workThread = new HandlerThread( GlobalAsyncThread.class.getSimpleName(), Process.THREAD_PRIORITY_BACKGROUND); workThread.start(); workHandler = new Handler(workThread.getLooper()); }