Android Looper - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Android Looper class.

This code example shows how to use the following methods:getThread, quit
     
    /* 
     * Terminates the message looper thread. 
     */ 
    private void terminateMessageLooper() throws Exception { 
        mLooper.quit();
        // Looper.quit() is asynchronous. The looper may still has some 
        // preview callbacks in the queue after quit is called. The preview 
        // callback still uses the camera object (setHasPreviewCallback). 
        // After camera is released, RuntimeException will be thrown from 
        // the method. So we need to join the looper thread here. 
        mLooper.getThread().join();
        mCamera.release();
    } 
     
    //Implement the previewCallback 
    private final class RawPreviewCallback implements PreviewCallback { 
        public void onPreviewFrame(byte [] rawData, Camera camera) {         
            Log.v(TAG, "Preview callback start");            
            int rawDataLength = 0;
8
CodeRank
This code example shows how to use the following methods:quit
    /* 
     * Terminates the listener looper thread. 
     */ 
    private void terminateListenerLooper() { 
        if (mLooper != null) {
            mLooper.quit();
            mLooper = null;
        } 
    } 
 
} 
6
CodeRank
This code example shows how to use the following methods:quit, sleep
     
    /* 
     * Terminates the message looper thread. 
     */ 
    private void terminateMessageLooper() { 
        mLooper.quit();
        //TODO yslau : take out the sleep until bug#1693519 fix 
        try { 
            Thread.sleep(1000);
        } catch (Exception e){
            Log.v(TAG, e.toString());
        } 
        mCamera.release();
    } 
     
    //Implement the previewCallback 
    private final class RawPreviewCallback implements PreviewCallback { 
        public void onPreviewFrame(byte [] rawData, Camera camera) {         
            Log.v(TAG, "Preview callback start");            
            int rawDataLength = 0;
6
CodeRank
This code example shows how to use the following methods:quit
     
    /* 
     * Terminates the message looper thread. 
     */ 
    private static void terminateMessageLooper() { 
        mLooper.quit();
        mMediaPlayer.release();
    } 
     
    static MediaPlayer.OnPreparedListener mPreparedListener = new MediaPlayer.OnPreparedListener() {
        public void onPrepared(MediaPlayer mp) { 
            synchronized (prepareDone) { 
                if(mPrepareReset){ 
                    Log.v(TAG, "call Reset"); 
                    mMediaPlayer.reset(); 
                } 
                Log.v(TAG, "notify the prepare callback"); 
                prepareDone.notify(); 
                onPrepareSuccess = true; 
            } 
6
CodeRank
This code example shows how to use the following methods:quit
 
    public void stopLooping() { 
      if (looper == null) {
        return; 
      } 
      looper.quit();
    } 
  } 
} 
5
CodeRank
This code example shows how to use the following methods:quit
		return mRedelivery ? START_REDELIVER_INTENT : START_NOT_STICKY;
	} 
 
	@Override 
	public void onDestroy() { 
		mServiceLooper.quit();
	} 
 
	@Override 
	public IBinder onBind(Intent intent) {
		return null; 
	} 
 
	/** 
	 * This method is invoked on the worker thread with a request to process. 
	 * Only one Intent is processed at a time, but the processing happens on a 
	 * worker thread that runs independently from other application logic. 
	 * So, if this code takes a long time, it will hold up other requests to 
	 * the same IntentService, but it will not hold up anything else. 
	 * 
5
CodeRank
This code example shows how to use the following methods:quit
        mServiceHandler.sendMessage(msg);
    } 
 
    @Override 
    public void onDestroy() { 
        mServiceLooper.quit();
    } 
 
    @Override 
    public IBinder onBind(Intent intent) {
        return null; 
    } 
 
    private static class ServiceHandler extends Handler {
 
        private final WeakReference<SmsReceiverService> mSmsReceiverService;
 
        public ServiceHandler(SmsReceiverService mSmsReceiverService,
                Looper looper) {
            super(looper);
5
CodeRank
This code example shows how to use the following methods:getThread, quit
 
    /* 
     * Terminates the message looper thread. 
     */ 
    private void terminateMessageLooper() throws Exception { 
        mLooper.quit();
        // Looper.quit() is asynchronous. The looper may still has some 
        // preview callbacks in the queue after quit is called. The preview 
        // callback still uses the camera object (setHasPreviewCallback). 
        // After camera is released, RuntimeException will be thrown from 
        // the method. So we need to join the looper thread here. 
        mLooper.getThread().join();
        mCamera.release();
    } 
 
    //Implement the previewCallback 
    private final class RawPreviewCallback implements PreviewCallback {
        public void onPreviewFrame(byte [] rawData, Camera camera) {
            Log.v(TAG, "Preview callback start");
            int rawDataLength = 0;
5
CodeRank
This code example shows how to use the following methods:setMessageLogging
        mService = new ConnectivityService(
                mServiceContext, mNetManager, mStatsService, mPolicyService, mNetFactory);
        mService.systemReady();
 
        mTrackerHandler = trackerHandler.getValue();
        mTrackerHandler.getLooper().setMessageLogging(new LogPrinter(Log.INFO, TAG));
    } 
 
    @Override 
    public void tearDown() throws Exception { 
        super.tearDown(); 
    } 
 
    public void testMobileConnectedAddedRoutes() throws Exception { 
        Future<?> nextConnBroadcast;
 
        // bring up mobile network 
        mMobile.info.setDetailedState(DetailedState.CONNECTED, null, null);
        mMobile.link.setInterfaceName(MOBILE_IFACE);
        mMobile.link.addRoute(MOBILE_ROUTE_V4);
5
CodeRank
This code example shows how to use the following methods:quit
        return START_REDELIVER_INTENT;
    } 
 
    @Override 
    public void onDestroy() { 
        mServiceLooper.quit();
    } 
 
    @Override 
    public IBinder onBind(Intent intent) {
        return null; 
    } 
} 
5
CodeRank

Related Android Looper Questions & Answers:

See Code Examples for Android Looper Methods: