Code example for Handler

Methods: sendEmptyMessageDelayed

0
    protected void onStart() { 
        if (mShowWarningIcon) {
            // Disable keyguard 
            mKeyguardLock.disableKeyguard();
            // start icon animation 
            mAnimationHandler.sendEmptyMessageDelayed(0, WARNING_ICON_ON_DURATION_MSEC);
        } 
    } 
 
    /** 
     * Stop animating warning icon and stop the {@link CellBroadcastAlertAudio} 
     * service if necessary. 
     */ 
    @Override 
    protected void onStop() { 
        // Stop playing alert sound/vibration/speech (if started) 
        Context context = getContext();
        context.stopService(new Intent(context, CellBroadcastAlertAudio.class));
        // Start database service to mark broadcast as read 
        Intent intent = new Intent(context, CellBroadcastDatabaseService.class);