List of usage examples for android.os HandlerThread getLooper
public Looper getLooper()
From source file:paulscode.android.mupen64plusae.jni.CoreService.java
@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_DEFAULT); thread.start();// w w w . j a v a 2 s . co m // Get the HandlerThread's Looper and use it for our Handler Looper serviceLooper = thread.getLooper(); mServiceHandler = new ServiceHandler(serviceLooper); }
From source file:com.android.camera.manager.ThumbnailViewManager.java
@Override public void begin() { Log.i(TAG, "[begin]..."); if (mWorkerHandler == null) { HandlerThread t = new HandlerThread("thumbnail-creation-thread"); t.start();/* ww w . j a v a 2s .c o m*/ mWorkerHandler = new WorkerHandler(t.getLooper()); } }
From source file:com.hmsoft.weargoproremote.services.WearMessageHandlerService.java
@Override public void onCreate() { super.onCreate(); if (Logger.DEBUG) Logger.debug(TAG, "Service created"); HandlerThread executorThread = new HandlerThread("WearMessageHandlerService"); executorThread.start();/*from w w w .j av a2 s .c o m*/ mExecutorLooper = executorThread.getLooper(); mWorkHandler = new Handler(mExecutorLooper, this); mPrefs = PreferenceManager.getDefaultSharedPreferences(this); mPass = mPrefs.getString(getString(R.string.preference_wifi_password_key), ""); mPreviewEnabled = mPrefs.getBoolean(getString(R.string.preference_watch_preview_enabled_key), true); mGoProController = GoProController.getDefaultInstance(mPass); mPrefs.registerOnSharedPreferenceChangeListener(this); mSendStatusTimer = new Timer(60000, mWorkHandler, new Timer.TimerTask() { @Override public void onTick(int ticks) { sendCameraStatus(); if (BuildConfig.DEBUG) Logger.debug(TAG, "Status sent..."); } }); updateNotification(getString(R.string.status_connection_starting)); }
From source file:net.xisberto.phonetodesktop.GoogleTasksActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Configure a background thread HandlerThread thread = new HandlerThread("PhoneToDesktopThread", Process.THREAD_PRIORITY_BACKGROUND); thread.start();//from w w w.j a v a 2 s. co m looper = thread.getLooper(); handler = new Handler(looper); // Configure app's preferences settings = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); accountManager = new GoogleAccountManager(getApplicationContext()); // Configure GoogleCredential. loadAuthToken can return null credential = new GoogleCredential(); log("Current saved token: " + loadAuthToken()); // Configure and build the Tasks object tasksService = new Tasks.Builder(transport, jsonFactory, credential).setApplicationName("PhoneToDesktop") .setJsonHttpRequestInitializer(new GoogleKeyInitializer(my_credentials.getAPIKey())).build(); if (getIntent().getAction().equals(ACTION_AUTHENTICATE)) { broadcastUpdatingStatus(ACTION_AUTHENTICATE, true); authorize(); } else if (getIntent().getAction().equals(Intent.ACTION_SEND)) { addTask(loadWhatToSend(), getIntent().getStringExtra(Intent.EXTRA_TEXT)); } else if (getIntent().getAction().equals(ACTION_LIST_TASKS)) { broadcastUpdatingStatus(ACTION_LIST_TASKS, true); getTaskList(); } else if (getIntent().getAction().equals(ACTION_REMOVE_TASKS)) { removeTask(getIntent().getStringExtra("task_id")); } }
From source file:org.durka.hallmonitor.CoreService.java
@Override public void onCreate() { Log.d(LOG_TAG + ".oC", "Core service creating"); localCoreService = this; mStateManager = ((CoreApp) getApplicationContext()).getStateManager(); Log.d(LOG_TAG + ".oC", "Register special actions"); mStateManager.registerCoreService(this); mStateManager.registerCoreReceiver(); mLocalBroadcastManager = LocalBroadcastManager.getInstance(this); HandlerThread thread = new HandlerThread("ServiceStartArguments", Process.THREAD_PRIORITY_BACKGROUND); thread.start();//w w w .j a va 2 s . com // Get the HandlerThread's Looper and use it for our Handler mTouchCoverLooper = thread.getLooper(); mTouchCoverHandler = new TouchCoverHandler(mTouchCoverLooper); lastTouchCoverRequest = mStateManager.getCoverClosed(); try { startActivityAsUser = ((ContextWrapper) this).getClass().getMethod("startActivityAsUser", Intent.class, UserHandle.class); Log.d(LOG_TAG, "startActivityAsUser registred"); } catch (NoSuchMethodException e) { e.printStackTrace(); } launchDefaultActivity = new Intent(localCoreService, DefaultActivity.class) .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_NO_ANIMATION | Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS); mUserHandle = android.os.Process.myUserHandle(); }
From source file:com.cssweb.android.quote.FenLei.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); HandlerThread mHandlerThread = new HandlerThread("CSSWEB_THREAD"); mHandlerThread.start();// www .j av a2 s . c o m mHandler = new MessageHandler(mHandlerThread.getLooper()); Bundle bundle = getIntent().getExtras(); this.requestType = bundle.getInt("requestType"); this.activityKind = Global.QUOTE_FENLEI; requestParams = new RequestParams(); requestParams.setMarket("SHSZA"); requestParams.setPaixu("zqdm"); setContentView(R.layout.zr_table); String[] toolbarname = new String[] { Global.TOOLBAR_MENU, Global.TOOLBAR_PINGZHONG, Global.TOOLBAR_PAIXU, Global.TOOLBAR_SHANGYE, Global.TOOLBAR_XIAYIYE, Global.TOOLBAR_REFRESH }; initTitle(R.drawable.njzq_title_left_back, 0, ""); initToolBar(toolbarname, Global.BAR_TAG); cols = getResources().getStringArray(R.array.stock_cols); menu = getResources().getStringArray(R.array.stock_type_menu); paiming = getResources().getStringArray(R.array.zqpm_menu); desc = getResources().getStringArray(R.array.stock_desc); //A title1 = menu[6]; //title2 = paiming[0]; //???? allStockNums = StockInfo.getStockInfoSize(stocktype); pageNum = CssSystem.getTablePageSize(FenLei.this); rowHeight = CssSystem.getTableRowHeight(FenLei.this); openOption(); openPopup(); requestParams.setBegin("1"); requestParams.setEnd(String.valueOf(pageNum)); setToolBar(3, false, R.color.zr_newlightgray); init(2); }
From source file:com.wlanjie.streaming.camera.CameraView.java
@Override public void onSurfaceCreated(GL10 gl, EGLConfig config) { GLES20.glDisable(GL10.GL_DITHER);//from w w w . j av a2 s. 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:com.cerema.cloud2.files.services.FileDownloader.java
/** * Service initialization// ww w .j av a2s. com */ @Override public void onCreate() { super.onCreate(); Log_OC.d(TAG, "Creating service"); mNotificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); HandlerThread thread = new HandlerThread("FileDownloaderThread", Process.THREAD_PRIORITY_BACKGROUND); thread.start(); mServiceLooper = thread.getLooper(); mServiceHandler = new ServiceHandler(mServiceLooper, this); mBinder = new FileDownloaderBinder(); // add AccountsUpdatedListener AccountManager am = AccountManager.get(getApplicationContext()); am.addOnAccountsUpdatedListener(this, null, false); }
From source file:nl.dobots.presence.PresenceDetectionApp.java
@Override public void onCreate() { super.onCreate(); instance = this; // load settings from persistent storage _settings = Settings.getInstance();/*from w ww .j a v a2s. c o m*/ _settings.readPersistentStorage(getApplicationContext()); _settings.readPersistentLocations(getApplicationContext()); // get localization algo _localization = new SimpleLocalization(_settings.getLocationsList(), _settings.getDetectionDistance()); // get ask wrapper (wraps login and presence functions) _ask = AskWrapper.getInstance(); _notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); // watchdog handler checks for non-presence and handles manual override HandlerThread watchdogThread = new HandlerThread("Watchdog"); watchdogThread.start(); _watchdogHandler = new Handler(watchdogThread.getLooper()); _watchdogHandler.postDelayed(_watchdogRunner, Config.WATCHDOG_INTERVAL); // network handler used for network operations (login, updatePresence, etc.) HandlerThread networkThread = new HandlerThread("NetworkHandler"); networkThread.start(); _networkHandler = new Handler(networkThread.getLooper()); // filter for connectivity broadcasts IntentFilter filter = new IntentFilter(); filter.addAction(ConnectivityManager.CONNECTIVITY_ACTION); registerReceiver(_receiver, filter); // Intent startServiceIntent = new Intent(this, BleScanService.class); // this.startService(startServiceIntent); Intent intent = new Intent(this, BleScanService.class); bindService(intent, _connection, Context.BIND_AUTO_CREATE); // set expiration time for RSSI measurements. keeps measurements of 5 scan intervals // before throwing them out. i.e. averages over all measurements received in the last 5 // scan intervals BleDevice.setExpirationTime(5 * (Config.LOW_SCAN_PAUSE + Config.LOW_SCAN_INTERVAL)); }
From source file:org.alljoyn.bus.samples.simpleclient.DevicesActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_devices); mContext = this; // mEditText = (EditText) findViewById(R.id.EditText); // mEditText.setOnEditorActionListener(new TextView.OnEditorActionListener() { // public boolean onEditorAction(TextView view, int actionId, KeyEvent event) { // if (actionId == EditorInfo.IME_NULL // && event.getAction() == KeyEvent.ACTION_UP) { // /* Call the remote object's Ping method. */ // Message msg = mBusHandler.obtainMessage(BusHandler.PING, // view.getText().toString()); // mBusHandler.sendMessage(msg); // } // return true; // } // }); //Master data list Fragment String fullName = SERVICE_NAME + ".coffeemaker.Beagle_Bone"; String[] tokens = fullName.split("[.]"); for (String token : tokens) { Log.i("token:", token); }//from w w w .jav a 2 s . co m mDeviceListFragment = new DeviceListFragment(); FragmentManager fragmentManager = getSupportFragmentManager(); FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); fragmentTransaction.add(R.id.myFragmentContainer, mDeviceListFragment, "DeviceListFragment"); fragmentTransaction.commit(); /* Make all AllJoyn calls through a separate handler thread to prevent blocking the UI. */ HandlerThread busThread = new HandlerThread("BusHandler"); busThread.start(); mBusHandler = new BusHandler(busThread.getLooper()); /* Connect to an AllJoyn object. */ mBusHandler.sendEmptyMessage(BusHandler.CONNECT); mHandler.sendEmptyMessage(MESSAGE_START_PROGRESS_DIALOG); }