Code example for Handler

Methods: post

0
    /* 
     * @override com.android.os.storage.StorageEventListener 
     */ 
    @Override 
    public void onUsbMassStorageConnectionChanged(final boolean connected) {
        mAsyncEventHandler.post(new Runnable() {
            @Override 
            public void run() { 
                onUsbMassStorageConnectionChangedAsync(connected);
            } 
        }); 
    } 
 
    private void onUsbMassStorageConnectionChangedAsync(boolean connected) {
        mUmsAvailable = connected;
        /* 
         * Even though we may have a UMS host connected, we the SD card 
         * may not be in a state for export. 
         */ 
        String st = Environment.getExternalStorageState();