List of usage examples for android.os HandlerThread HandlerThread
public HandlerThread(String name)
From source file:at.andreasrohner.spartantimelapserec.BackgroundService.java
@Override public void surfaceCreated(final SurfaceHolder surfaceHolder) { handlerThread = new HandlerThread("recordingVideo"); handlerThread.start();//ww w . jav a 2 s.c om Context context = getApplicationContext(); Handler handler = new Handler(handlerThread.getLooper(), this); recorder = Recorder.getInstance(settings, surfaceHolder, context, handler, wakeLock); handler.post(new Runnable() { @Override public void run() { recorder.start(); } }); }
From source file:com.wlanjie.streaming.camera.CameraView.java
@Override public void onSurfaceCreated(GL10 gl, EGLConfig config) { GLES20.glDisable(GL10.GL_DITHER);//from ww w . ja va 2s . co m GLES20.glClearColor(1.0f, 1.0f, 1.0f, 1.0f); HandlerThread thread = new HandlerThread("glDraw"); thread.start(); mHandler = new Handler(thread.getLooper()) { @Override public void handleMessage(Message msg) { super.handleMessage(msg); IntBuffer buffer = mEglCore.getRgbaBuffer(); mFrameBuffer.asIntBuffer().put(buffer.array()); if (mCallback != null) { mCallback.onPreviewFrame(CameraView.this, mFrameBuffer.array()); } } }; mEglCore = new EglCore(getResources()); mEglCore.init(); mSurfaceTexture.setOnFrameAvailableListener(new SurfaceTexture.OnFrameAvailableListener() { @Override public void onFrameAvailable(SurfaceTexture surfaceTexture) { mGLSurfaceView.requestRender(); } }); }
From source file:cz.muni.fi.japanesedictionary.parser.ParserService.java
@Override public void onCreate() { super.onCreate(); HandlerThread thread = new HandlerThread("IntentService[Dictionary_parser]"); thread.start();/* ww w .jav a 2s . c o m*/ mServiceLooper = thread.getLooper(); mServiceHandler = new ServiceHandler(mServiceLooper); setIntentRedelivery(true); }
From source file:nl.dobots.bluenet.ble.extended.BleExt.java
public BleExt() { _bleBase = new BleBase(); _bleExtState = new BleExtState(this); // create handler with its own thread HandlerThread handlerThread = new HandlerThread("BleExtHandler"); handlerThread.start();/*from w w w . jav a2 s.com*/ _handler = new Handler(handlerThread.getLooper()); }
From source file:org.compose.mobilesdk.android.COMPOSESubService.java
@Override public void onCreate() { super.onCreate(); mDeviceId = String.format(DEVICE_ID_FORMAT, Secure.getString(getContentResolver(), Secure.ANDROID_ID)); HandlerThread thread = new HandlerThread(MQTT_THREAD_NAME); thread.start();//from ww w . ja v a 2 s . c o m mConnHandler = new Handler(thread.getLooper()); try { mDataStore = new MqttDefaultFilePersistence(getCacheDir().getAbsolutePath()); } catch (Exception e) { e.printStackTrace(); mDataStore = null; mMemStore = new MemoryPersistence(); } mOpts = new MqttConnectOptions(); mOpts.setCleanSession(MQTT_CLEAN_SESSION); // Do not set keep alive interval on mOpts we keep track of it with alarm's mAlarmManager = (AlarmManager) getSystemService(ALARM_SERVICE); mConnectivityManager = (ConnectivityManager) getSystemService(CONNECTIVITY_SERVICE); }
From source file:com.bruce.study.demo.base.BaseFragment.java
/** * ?handleWorkerMessage??initWorkerHandler??mWorkerHandlermHandlerThread * * @param name/*from w w w .j a v a 2s . com*/ */ public void initWorkerHandler(String name) { if (mHandlerThread == null && mWorkerHandler == null) { mHandlerThread = new HandlerThread(name); mHandlerThread.start(); mWorkerHandler = new WorkerHandler(mHandlerThread.getLooper(), this); } else { logE("initWorkerHandler is called ,don't called again!"); } }
From source file:org.ymkm.lib.controller.support.ControlledDialogFragment.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Bundle b = getArguments();/*from w w w . j a va2 s .c o m*/ if (null == b) { b = new Bundle(); } // Creates a new thread supplying a Looper for the Handler if creation // requested to run in a new thread. boolean newThread = b.getBoolean("__new_thread__", (null != savedInstanceState && savedInstanceState.getBoolean("__new_thread__", false))); mControllableName = b.getString("__controllable_name__"); mControllableName = (null == mControllableName && null != savedInstanceState) ? savedInstanceState.getString("__controllable_name__") : mControllableName; mControlId = b.getInt("__control_id__", 0); mControlId = (0 == mControlId && null != savedInstanceState) ? savedInstanceState.getInt("__control_id__", 0) : mControlId; if (newThread) { synchronized (this) { if (null == _handlerThread) { this._handlerThread = new HandlerThread(getFragmentName()); _handlerThread.start(); } } } else { _handlerThread = null; } if (null != _handlerThread) { this.mHandler = new Handler(_handlerThread.getLooper(), getCallback()); } else { this.mHandler = new Handler(getCallback()); } }
From source file:cn.yibulz.caviewtest.MainActivity.java
private Handler getBackgroundHandler() { if (mBackgroundHandler == null) { HandlerThread thread = new HandlerThread("background"); thread.start();/*from w w w. j a va 2 s. c o m*/ mBackgroundHandler = new Handler(thread.getLooper()); } return mBackgroundHandler; }
From source file:com.android.camera.v2.uimanager.ThumbnailManager.java
/** * Create a thumbnail manager controller. * @param appcontroller controller used to get service for storage. * @param activity the current activity. * @param parent view group./*from w ww . j a va 2s. co m*/ * @param secureCamera whether the current camera is secure camera or not. */ public ThumbnailManager(AppController appcontroller, Activity activity, ViewGroup parent, boolean secureCamera) { super(activity, parent); mIsSecureCamera = secureCamera; setFilterEnable(false); mStorageService = appcontroller.getAppControllerAdapter().getServices().getStorageService(); mActivity = activity; mContentResolver = activity.getContentResolver(); mMaiHandler = new Handler(activity.getMainLooper()); HandlerThread t = new HandlerThread("thumbnail-creation-thread"); t.start(); mHandler = new ThumbnailCreatorHandler(t.getLooper()); mThumbnailAnimation = new ThumbnailAnimation(); LocalBroadcastManager manager = LocalBroadcastManager.getInstance(mActivity); manager.registerReceiver(mUpdatePictureReceiver, mUpdatePictureFilter); mActivity.registerReceiver(mIpoShutdownReceiver, mIpoShutdownFilter); mIntent = activity.getIntent(); String action = null; if (mIntent != null) { action = mIntent.getAction(); } if (MediaStore.ACTION_IMAGE_CAPTURE.equals(action) || MediaStore.ACTION_VIDEO_CAPTURE.equals(action) || CameraUtil.ACTION_STEREO3D.equals(action)) { mShownByIntent = false; } }
From source file:edu.mit.media.funf.pipeline.BasicPipeline.java
@Override public void onCreate(FunfManager manager) { if (archive == null) { archive = new DefaultArchive(manager, name); }// w ww.j a v a2 s . c o m if (uploader == null) { uploader = new UploadService(manager); uploader.start(); } this.manager = manager; reloadDbHelper(manager); HandlerThread thread = new HandlerThread(getClass().getName()); thread.start(); this.looper = thread.getLooper(); this.handler = new Handler(looper, callback); enabled = true; for (JsonElement dataRequest : data) { manager.requestData(this, dataRequest); } for (Map.Entry<String, Schedule> schedule : schedules.entrySet()) { manager.registerPipelineAction(this, schedule.getKey(), schedule.getValue()); } }