List of usage examples for android.os HandlerThread start
public synchronized void start()
From source file:grupo19.locmess19.Services.LocationUpdatesService.java
@SuppressLint("WifiManagerLeak") @Override/*from w w w . j a v a 2 s. c om*/ public void onCreate() { mGoogleApiClient = new GoogleApiClient.Builder(this).addConnectionCallbacks(this) .addOnConnectionFailedListener(this).addApi(LocationServices.API).build(); mGoogleApiClient.connect(); createLocationRequest(); HandlerThread handlerThread = new HandlerThread(TAG); handlerThread.start(); mServiceHandler = new Handler(handlerThread.getLooper()); mNotificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); server = new ServerCommunication("10.0.2.2", 11113); }
From source file:eu.faircode.netguard.SinkholeService.java
@Override public void onCreate() { super.onCreate(); Log.i(TAG, "Create"); HandlerThread thread = new HandlerThread(getString(R.string.app_name)); thread.start(); mServiceLooper = thread.getLooper(); mServiceHandler = new ServiceHandler(mServiceLooper); // Listen for interactive state changes IntentFilter ifInteractive = new IntentFilter(); ifInteractive.addAction(Intent.ACTION_SCREEN_ON); ifInteractive.addAction(Intent.ACTION_SCREEN_OFF); registerReceiver(interactiveStateReceiver, ifInteractive); // Listen for connectivity updates IntentFilter ifConnectivity = new IntentFilter(); ifConnectivity.addAction(ConnectivityManager.CONNECTIVITY_ACTION); registerReceiver(connectivityChangedReceiver, ifConnectivity); // Listen for added applications IntentFilter ifPackage = new IntentFilter(); ifPackage.addAction(Intent.ACTION_PACKAGE_ADDED); ifPackage.addDataScheme("package"); registerReceiver(packageAddedReceiver, ifPackage); }
From source file:com.twp.music.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Logger.i(TAG, "onCreate ---- "); setContentView(R.layout.activity_main); fm = getFragmentManager();//from www . j av a 2s. co m initView(); token = MusicUtils.bindToService(this, this); //start ? ?? ?looperhandler HandlerThread alnumArtThread = new HandlerThread("Album Art HandlerThread "); alnumArtThread.start(); albumArtHandler = new AlbumArtHandler(alnumArtThread.getLooper()); }
From source file:paulscode.android.mupen64plusae.task.CacheRomInfoService.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_BACKGROUND); thread.start(); // Get the HandlerThread's Looper and use it for our Handler mServiceLooper = thread.getLooper(); mServiceHandler = new ServiceHandler(mServiceLooper); //Show the notification Intent notificationIntent = new Intent(this, GalleryActivity.class); PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0); NotificationCompat.Builder builder = new NotificationCompat.Builder(this).setSmallIcon(R.drawable.icon) .setContentTitle(getString(R.string.scanning_title)) .setContentText(getString(R.string.toast_pleaseWait)).setContentIntent(pendingIntent); startForeground(ONGOING_NOTIFICATION_ID, builder.build()); }
From source file:org.anhonesteffort.flock.ExportService.java
@Override public void onCreate() { HandlerThread thread = new HandlerThread(getClass().getSimpleName(), HandlerThread.NORM_PRIORITY); thread.start(); serviceHandler = new ServiceHandler(thread.getLooper()); notifyManager = (NotificationManager) getBaseContext().getSystemService(Context.NOTIFICATION_SERVICE); notificationBuilder = new NotificationCompat.Builder(getBaseContext()); }
From source file:com.bitants.wally.fragments.RandomImagesFragment.java
private void setupHandlers() { HandlerThread handlerThread = new HandlerThread("RandomImages.background"); handlerThread.start(); backgroundHandler = new Handler(handlerThread.getLooper(), this); uiHandler = new Handler(getActivity().getMainLooper(), this); }
From source file:org.dvbviewer.controller.service.SyncService.java
@Override public void onCreate() { Log.i(SyncService.class.getSimpleName(), "onCreate"); mNotificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); DVBViewerPreferences dvbPrefs = new DVBViewerPreferences(getApplication()); prefs = dvbPrefs.getPrefs();// w ww. java2s. c o m HandlerThread thread = new HandlerThread(SyncService.class.getName(), Process.THREAD_PRIORITY_BACKGROUND); thread.start(); mServiceLooper = thread.getLooper(); mServiceHandler = new ServiceHandler(mServiceLooper); }
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./* w w w .java2 s . com*/ * @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: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(); // Get the HandlerThread's Looper and use it for our Handler Looper serviceLooper = thread.getLooper(); mServiceHandler = new ServiceHandler(serviceLooper); }
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(); mConnHandler = new Handler(thread.getLooper()); try {/*ww w.ja v a2s . co m*/ 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); }