Example usage for android.os HandlerThread getLooper

List of usage examples for android.os HandlerThread getLooper

Introduction

In this page you can find the example usage for android.os HandlerThread getLooper.

Prototype

public Looper getLooper() 

Source Link

Document

This method returns the Looper associated with this thread.

Usage

From source file:com.binoy.vibhinna.CustomIntentService.java

@Override
public void onCreate() {
    // TODO: It would be nice to have an option to hold a partial wakelock
    // during processing, and to have a static startService(Context, Intent)
    // method that would launch the service & hand off a wakelock.

    super.onCreate();
    HandlerThread thread = new HandlerThread("IntentService[" + mName + "]");
    thread.start();/*from  w ww . j  a  v a2  s  .  com*/

    mServiceLooper = thread.getLooper();
    mServiceHandler = new ServiceHandler(mServiceLooper);
}

From source file:fr.enseirb.odroidx.videomanager.Uploader.java

public void onCreate() {
    Log.i(getClass().getSimpleName(), "Uploader on create");
    HandlerThread thread = new HandlerThread("Uploader");
    thread.start();/*w  ww.j av  a  2  s  .c  o m*/

    mUploadLooper = thread.getLooper();
    mUploadHandler = new ServiceHandler(mUploadLooper);
}

From source file:org.peercast.pecaport.PecaPortService.java

@Override
public void onCreate() {
    super.onCreate();
    logger.info(getString(R.string.t_log_starting) + "PecaPortService");

    HandlerThread thread = new HandlerThread(TAG);
    thread.start();//from  ww  w.j a  v a2 s  . c  o  m

    mServiceHandler = new ServiceHandler(thread.getLooper());
    mUiThreadHandler = new Handler(Looper.getMainLooper());
    mRouterDiscoverer = new RouterDiscoverer(getApplicationContext(), this);

    NetworkDeviceManager nicManager = NetworkDeviceManager.from(this);
    mActiveNicInfo = nicManager.getActiveInterface();
}

From source file:com.snt.bt.recon.services.BcScanService.java

@Override
public int onStartCommand(Intent intent, int flags, int startId) {

    //leave cpu on
    wl = ((PowerManager) getSystemService(Context.POWER_SERVICE)).newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,
            "wlTag2");
    wl.acquire();/*from  w  w  w.  j  a v a2s  . c  om*/

    HandlerThread handlerThread = new HandlerThread("ht");
    handlerThread.start();
    Looper looper = handlerThread.getLooper();
    handler = new Handler(looper);

    //show notification
    showNotification();

    if (intent != null) {
        final String action = intent.getAction();
        if (ACTION_START_SCAN.equals(action)) {
            //final String param1 = intent.getStringExtra(EXTRA_LAT);
            sessionId = UUID.fromString(intent.getStringExtra(EXTRA_SID));
            handleActionStartScan();

        }
    }
    return START_STICKY;
}

From source file:com.example.android.downloadablefonts.MainActivity.java

private Handler getHandlerThreadHandler() {
    if (mHandler == null) {
        HandlerThread handlerThread = new HandlerThread("fonts");
        handlerThread.start();/* ww w . j  a  v a 2s . c o  m*/
        mHandler = new Handler(handlerThread.getLooper());
    }
    return mHandler;
}

From source file:com.grass.caishi.cc.service.BaseIntentService.java

/**
 * Creates an IntentService. Invoked by your subclass's constructor.
 * //from www .j a v  a2s  .c om
 * @param name
 *            Used to name the worker thread, important only for debugging.
 */
// public BaseIntentService(Context context){
// super(context);
// }

// public class BroadCastListen extends BroadcastReceiver{
// @Override
// public void onReceive(Context context, Intent intent) {
// // TODO Auto-generated method stub
// int ddo=intent.getIntExtra("do", 0);
// int fileid=intent.getIntExtra("imageId", 0);
// String str=intent.getAction();
// if(str.equals(broadcase)&&ddo==UP_DEL&&fileid!=0){
// mServiceHandler.removeMessages(fileid);
// for (int i = 0; i < filelist.size(); i++) {
// ImageItem fu=filelist.get(i);
// if(fu.imageId==fileid){
// filelist.remove(i);
// intent.putExtra("do", UP_DEL);
// sendBroadcast(intent);
// break;
// }
// }
// }
// }
// }

@Override
public void onCreate() {
    super.onCreate();
    // filelist.clear();
    intent = new Intent(BroadCastName);
    // broadcase=new BroadCastListen();
    // IntentFilter filter=new IntentFilter(BroadCastName);
    // registerReceiver(broadcase, filter);

    HandlerThread thread = new HandlerThread("IntentService[" + mName + "]");
    thread.start();

    mServiceLooper = thread.getLooper();
    mServiceHandler = new ServiceHandler(mServiceLooper);
}

From source file:MainActivity.java

private void startPreview(CameraCaptureSession session) {
    mCameraCaptureSession = session;//from www .  ja v a2s .c  o  m
    mCaptureRequestBuilder.set(CaptureRequest.CONTROL_MODE, CameraMetadata.CONTROL_MODE_AUTO);
    HandlerThread backgroundThread = new HandlerThread("CameraPreview");
    backgroundThread.start();
    Handler backgroundHandler = new Handler(backgroundThread.getLooper());
    try {
        mCameraCaptureSession.setRepeatingRequest(mCaptureRequestBuilder.build(), null, backgroundHandler);
    } catch (CameraAccessException e) {
        e.printStackTrace();
    }
}

From source file:org.anhonesteffort.flock.ContactCopyService.java

@Override
public void onCreate() {
    HandlerThread thread = new HandlerThread("ContactCopyService", HandlerThread.NORM_PRIORITY);
    thread.start();//  ww  w. j  ava 2s .c o m

    serviceLooper = thread.getLooper();
    serviceHandler = new ServiceHandler(serviceLooper);

    notifyManager = (NotificationManager) getBaseContext().getSystemService(Context.NOTIFICATION_SERVICE);
    notificationBuilder = new NotificationCompat.Builder(getBaseContext());
    accountErrors = new LinkedList<Bundle>();
}

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.  ja v a  2s  .  c o m*/
        mBackgroundHandler = new Handler(thread.getLooper());
    }
    return mBackgroundHandler;
}

From source file:com.lithiumli.fiction.NowPlayingActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.now_playing);
    initializeDrawer(false);/*  w  ww  .ja  va  2s  .  c  om*/

    mCoverPager = (AlbumSwiper) findViewById(R.id.cover_pager);
    mCoverPager.setListener(this);

    mSongName = (TextView) findViewById(R.id.np_song_name);
    mSongAlbum = (TextView) findViewById(R.id.np_song_album);
    mSongArtist = (TextView) findViewById(R.id.np_song_artist);
    mSongArtist.setSelected(true);

    ActionBar ab = getActionBar();
    ab.setDisplayHomeAsUpEnabled(true);
    ab.setTitle("Now Playing");

    mCache = ArtistImageCache.getInstance(this);

    setQueueMargin();

    HandlerThread thread = new HandlerThread("thread");
    thread.start();

    mLooper = thread.getLooper();
    mHandler = new Handler(mLooper);

    mFadeOut = new FadeOut();
    mHandler.postDelayed(mFadeOut, 2000);
}