List of usage examples for android.os HandlerThread start
public synchronized void start()
From source file:com.vk.sdk.payments.VKPaymentsServerSender.java
private VKPaymentsServerSender(@NonNull Context ctx) { mAppCtx = ctx;/*www . j a v a2 s.c o m*/ mCheckUserInstallAnswer = restoreAnswer(ctx); HandlerThread handlerThread = new HandlerThread(getClass().getName()); handlerThread.start(); mHandler = new Handler(handlerThread.getLooper()); // !!! WARNING !!! this for wait reference url from vk client mHandler.post(new Runnable() { @Override public void run() { try { Thread.sleep(1000); // time for wait reference url } catch (Exception e) { // nothing } } }); }
From source file:cn.studyjams.s2.sj0132.bowenyan.mygirlfriend.nononsenseapps.notepad.data.service.OrgSyncService.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 serviceLooper = thread.getLooper();/* w w w . j a va 2s . com*/ serviceHandler = new SyncHandler(serviceLooper); }
From source file:org.peercast.core.PeerCastService.java
@Override public void onCreate() { super.onCreate(); HandlerThread thread = new HandlerThread("PeerCastService", Thread.MIN_PRIORITY); thread.start(); serviceLooper = thread.getLooper();//from w w w.j a v a 2s .c o m serviceHandler = new ServiceHandler(serviceLooper); serviceMessenger = new Messenger(serviceHandler); }
From source file:ch.carteggio.provider.sync.NotificationService.java
@Override public void onCreate() { super.onCreate(); HandlerThread thread = new HandlerThread("NotificationService"); thread.start(); mServiceLooper = thread.getLooper(); mServiceHandler = new ServiceHandler(mServiceLooper); mObserver = new Observer(); getContentResolver().registerContentObserver(CarteggioContract.Messages.CONTENT_URI, true, mObserver); }
From source file:com.irccloud.android.IRCCloudApplicationBase.java
private Handler getFontsHandler() { if (mFontsHandler == null) { HandlerThread handlerThread = new HandlerThread("fonts"); handlerThread.start(); mFontsHandler = new Handler(handlerThread.getLooper()); }//from ww w . j a v a 2 s . com return mFontsHandler; }
From source file:org.anhonesteffort.flock.CalendarCopyService.java
@Override public void onCreate() { HandlerThread thread = new HandlerThread("CalendarCopyService", HandlerThread.NORM_PRIORITY); thread.start(); serviceLooper = thread.getLooper();// w w w .ja va2s .c om serviceHandler = new ServiceHandler(serviceLooper); notifyManager = (NotificationManager) getBaseContext().getSystemService(Context.NOTIFICATION_SERVICE); notificationBuilder = new NotificationCompat.Builder(getBaseContext()); accountErrors = new LinkedList<Bundle>(); }
From source file:com.mozilla.autophone.usbwatchdog.USBService.java
@Override public void onCreate() { HandlerThread thread = new HandlerThread("ServiceStartArguments", android.os.Process.THREAD_PRIORITY_BACKGROUND); thread.start(); int permission = ContextCompat.checkSelfPermission(this, Manifest.permission.REBOOT); mPermissions = (permission == PackageManager.PERMISSION_GRANTED); permission = ContextCompat.checkSelfPermission(this, Manifest.permission.DUMP); mPermissions = mPermissions && (permission == PackageManager.PERMISSION_GRANTED); if (mPermissions) { Log.i("USBWatchdog", "Permissions granted. Using PowerManager."); } else {/*from w w w.ja va 2 s .c o m*/ Log.i("USBWatchdog", "Permissions not granted. Using su."); } mServiceLooper = thread.getLooper(); mServiceHandler = new ServiceHandler(mServiceLooper, mPermissions); }
From source file:com.csipsimple.utils.ContactsAsyncHelper.java
/** * Private constructor for static class/*from w w w . ja va2 s.co m*/ */ private ContactsAsyncHelper() { HandlerThread thread = new HandlerThread("ContactsAsyncWorker"); thread.start(); sThreadHandler = new WorkerHandler(thread.getLooper()); contactsWrapper = ContactsWrapper.getInstance(); }
From source file:com.uphyca.idobata.android.service.IdobataService.java
private void ensureHandler() { HandlerThread t = new HandlerThread("IdobataService", Process.THREAD_PRIORITY_BACKGROUND); t.start(); mServiceLooper = t.getLooper();/* w ww .j av a2 s .c o m*/ mServiceHandler = new ServiceHandler(mServiceLooper); }
From source file:com.peptrack.gps.locationupdatesforegroundservice.LocationUpdatesService.java
@Override public void onCreate() { mFusedLocationClient = LocationServices.getFusedLocationProviderClient(this); mLocationCallback = new LocationCallback() { @Override/* w w w. ja va2 s . co m*/ public void onLocationResult(LocationResult locationResult) { super.onLocationResult(locationResult); onNewLocation(locationResult.getLastLocation()); } }; createLocationRequest(); getLastLocation(); HandlerThread handlerThread = new HandlerThread(TAG); handlerThread.start(); mServiceHandler = new Handler(handlerThread.getLooper()); mNotificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); // Android O requires a Notification Channel. if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { CharSequence name = getString(R.string.app_name); // Create the channel for the notification NotificationChannel mChannel = new NotificationChannel(CHANNEL_ID, name, NotificationManager.IMPORTANCE_DEFAULT); // Set the Notification Channel for the Notification Manager. mNotificationManager.createNotificationChannel(mChannel); } }