Example usage for android.content Intent ACTION_MEDIA_UNMOUNTED

List of usage examples for android.content Intent ACTION_MEDIA_UNMOUNTED

Introduction

In this page you can find the example usage for android.content Intent ACTION_MEDIA_UNMOUNTED.

Prototype

String ACTION_MEDIA_UNMOUNTED

To view the source code for android.content Intent ACTION_MEDIA_UNMOUNTED.

Click Source Link

Document

Broadcast Action: External media is present, but not mounted at its mount point.

Usage

From source file:com.android.music.TrackBrowserFragment.java

public void onServiceConnected(ComponentName name, IBinder service) {
    IntentFilter f = new IntentFilter();
    f.addAction(Intent.ACTION_MEDIA_SCANNER_STARTED);
    f.addAction(Intent.ACTION_MEDIA_SCANNER_FINISHED);
    f.addAction(Intent.ACTION_MEDIA_UNMOUNTED);
    f.addDataScheme("file");
    getActivity().registerReceiver(mScanListener, f);

    if (mAdapter == null) {
        //Log.i("@@@", "starting query");
        mAdapter = new TrackListAdapter(getActivity().getApplication(), // need to use application context to avoid leaks
                this, mEditMode ? R.layout.edit_track_list_item : R.layout.track_list_item, null, // cursor
                new String[] {}, new int[] {}, "nowplaying".equals(mPlaylist),
                mPlaylist != null && !(mPlaylist.equals("podcasts") || mPlaylist.equals("recentlyadded")));
        mTrackList.setAdapter(mAdapter);
        //getActivity().setTitle(R.string.working_songs);
        getTrackCursor(mAdapter.getQueryHandler(), null, true);
    } else {//from w w w.  ja  v  a2 s  .  c om
        mTrackCursor = mAdapter.getCursor();
        // If mTrackCursor is null, this can be because it doesn't have
        // a cursor yet (because the initial query that sets its cursor
        // is still in progress), or because the query failed.
        // In order to not flash the error dialog at the user for the
        // first case, simply retry the query when the cursor is null.
        // Worst case, we end up doing the same query twice.
        if (mTrackCursor != null) {
            init(mTrackCursor, false);
        } else {
            //getActivity(). setTitle(R.string.working_songs);
            getTrackCursor(mAdapter.getQueryHandler(), null, true);
        }
    }
    if (!mEditMode) {
        MusicUtils.updateNowPlaying(getActivity());
    }
}

From source file:com.aware.Aware.java

@Override
public void onCreate() {
    super.onCreate();

    awareContext = getApplicationContext();

    aware_preferences = getSharedPreferences("aware_core_prefs", MODE_PRIVATE);
    if (aware_preferences.getAll().isEmpty()) {
        SharedPreferences.Editor editor = aware_preferences.edit();
        editor.putInt(PREF_FREQUENCY_WATCHDOG, CONST_FREQUENCY_WATCHDOG);
        editor.putLong(PREF_LAST_SYNC, 0);
        editor.putLong(PREF_LAST_UPDATE, 0);
        editor.commit();// www.  j  av  a 2s  .co  m
    }

    IntentFilter filter = new IntentFilter();
    filter.addAction(Intent.ACTION_MEDIA_MOUNTED);
    filter.addAction(Intent.ACTION_MEDIA_UNMOUNTED);
    filter.addDataScheme("file");
    awareContext.registerReceiver(storage_BR, filter);

    filter = new IntentFilter();
    filter.addAction(Aware.ACTION_AWARE_CLEAR_DATA);
    filter.addAction(Aware.ACTION_AWARE_REFRESH);
    filter.addAction(Aware.ACTION_AWARE_SYNC_DATA);
    filter.addAction(DownloadManager.ACTION_DOWNLOAD_COMPLETE);
    awareContext.registerReceiver(aware_BR, filter);

    alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE);

    awareStatusMonitor = new Intent(getApplicationContext(), Aware.class);
    repeatingIntent = PendingIntent.getService(getApplicationContext(), 0, awareStatusMonitor, 0);
    alarmManager.setRepeating(AlarmManager.RTC_WAKEUP, System.currentTimeMillis() + 1000,
            aware_preferences.getInt(PREF_FREQUENCY_WATCHDOG, 300) * 1000, repeatingIntent);

    Intent synchronise = new Intent(Aware.ACTION_AWARE_SYNC_DATA);
    webserviceUploadIntent = PendingIntent.getBroadcast(getApplicationContext(), 0, synchronise, 0);

    if (!Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
        stopSelf();
    } else {
        SharedPreferences prefs = getSharedPreferences(getPackageName(), Context.MODE_PRIVATE);
        if (prefs.getAll().isEmpty()
                && Aware.getSetting(getApplicationContext(), Aware_Preferences.DEVICE_ID).length() == 0) {
            PreferenceManager.setDefaultValues(getApplicationContext(), getPackageName(), Context.MODE_PRIVATE,
                    R.xml.aware_preferences, true);
            prefs.edit().commit(); //commit changes
        } else {
            PreferenceManager.setDefaultValues(getApplicationContext(), getPackageName(), Context.MODE_PRIVATE,
                    R.xml.aware_preferences, false);
        }

        Map<String, ?> defaults = prefs.getAll();
        for (Map.Entry<String, ?> entry : defaults.entrySet()) {
            if (Aware.getSetting(getApplicationContext(), entry.getKey()).length() == 0) {
                Aware.setSetting(getApplicationContext(), entry.getKey(), entry.getValue());
            }
        }

        if (Aware.getSetting(getApplicationContext(), Aware_Preferences.DEVICE_ID).length() == 0) {
            UUID uuid = UUID.randomUUID();
            Aware.setSetting(getApplicationContext(), Aware_Preferences.DEVICE_ID, uuid.toString());
        }

        DEBUG = Aware.getSetting(awareContext, Aware_Preferences.DEBUG_FLAG).equals("true");
        TAG = Aware.getSetting(awareContext, Aware_Preferences.DEBUG_TAG).length() > 0
                ? Aware.getSetting(awareContext, Aware_Preferences.DEBUG_TAG)
                : TAG;

        get_device_info();

        if (Aware.DEBUG)
            Log.d(TAG, "AWARE framework is created!");

        //Fixed: only the client application does a ping to AWARE's server
        if (getPackageName().equals("com.aware")) {
            new AsyncPing().execute();
        }
    }
}

From source file:com.loloof64.android.chess_position_manager.MainActivity.java

@Override
protected void onResume() {
    super.onResume();

    IntentFilter filter = new IntentFilter();
    filter.addAction(Intent.ACTION_MEDIA_REMOVED);
    filter.addAction(Intent.ACTION_MEDIA_BAD_REMOVAL);
    filter.addAction(Intent.ACTION_MEDIA_EJECT);
    filter.addAction(Intent.ACTION_MEDIA_NOFS);
    filter.addAction(Intent.ACTION_MEDIA_SHARED);
    filter.addAction(Intent.ACTION_MEDIA_UNMOUNTED);
    registerReceiver(mStorageReceiver, filter);
}

From source file:net.kidlogger.kidlogger.KLService.java

public void setupLogging() {
    // Set up GPS / Network logging      
    if (Settings.loggingGps(this)) {
        startGpsUpdates();/*w  w w .  ja v a 2 s  .  c  o  m*/
        gpsOn = true;
    }

    // Set up WiFi logging
    if (Settings.loggingWifi(this)) {
        wifiReceiver = new WifiReceiver(this);
        registerReceiver(wifiReceiver, new IntentFilter(WifiManager.NETWORK_STATE_CHANGED_ACTION));
        wifiOn = true;
    }

    // Set up SMS logging
    if (Settings.loggingSms(this)) {
        smsObserver = new SmsObserver(this, handlering);
        IntentFilter smsFilter = new IntentFilter(SMS_RECEIVED);
        registerReceiver(smsObserver.inSms, smsFilter);
        smsOn = true;
    }

    // Set up Calls logging
    if (Settings.loggingCalls(this)) {
        IntentFilter callsFilter = new IntentFilter(TelephonyManager.ACTION_PHONE_STATE_CHANGED);

        callsReceiver = new CallsReceiver(this);
        registerReceiver(callsReceiver, callsFilter);
        callOn = true;
    }

    // Set up Idle logging
    IntentFilter idleFilter = new IntentFilter(Intent.ACTION_SCREEN_OFF);
    idleFilter.addAction(Intent.ACTION_USER_PRESENT);

    idleReceiver = new IdleReceiver(this);
    registerReceiver(idleReceiver, idleFilter);
    idleOn = true;
    /*if(Settings.loggingIdle(this)){
       IntentFilter idleFilter = new IntentFilter(Intent.ACTION_SCREEN_OFF);
       idleFilter.addAction(Intent.ACTION_USER_PRESENT);
               
       idleReceiver = new IdleReceiver(this);
       registerReceiver(idleReceiver, idleFilter);
       idleOn = true;
    }*/

    // Set up URL logging
    if (Settings.loggingUrl(this)) {
        urlObserver = new HistoryObserver(this, handlering);
        urlOn = true;
    }

    // Set up USB logging
    if (Settings.loggingUsb(this)) {
        IntentFilter usbFilter = new IntentFilter(Intent.ACTION_UMS_CONNECTED);
        usbFilter.addAction(Intent.ACTION_UMS_DISCONNECTED);

        usbReceiver = new UsbReceiver(this);
        registerReceiver(usbReceiver, usbFilter);
        usbOn = true;
    }

    // Set up Tasks logging
    if (logTask) {
        // Check if a new Application was started
        taskScan = new Runnable() {
            public void run() {
                new Thread(new Runnable() {
                    public void run() {
                        doScanTask();
                    }
                }).start();
                if (userPresent) {
                    handleTask.postDelayed(this, SCAN_TASK_TIME);
                    scanningTask = true;
                } else {
                    scanningTask = false;
                }
            }
        };
        handleTask.postDelayed(taskScan, SCAN_TASK_TIME);
        taskOn = true;
    }

    // Set up Clipboard logging
    if (logClip) {
        // Scan clipboard content, only first 30 characters
        clipboardScan = new Runnable() {
            public void run() {
                new Thread(new Runnable() {
                    public void run() {
                        doScanClipboard();
                    }
                }).start();
                if (userPresent) {
                    handleClipb.postDelayed(this, SCAN_CLIP_TIME);
                    scanningClip = true;
                } else {
                    scanningClip = false;
                }
            }
        };
        handleClipb.postDelayed(clipboardScan, SCAN_CLIP_TIME);
        clipOn = true;
    }

    // Set up Power logging
    if (Settings.loggingPower(this)) {
        IntentFilter powerFilter = new IntentFilter(Intent.ACTION_SHUTDOWN);

        powerReceiver = new ShutdownReceiver(this);
        registerReceiver(powerReceiver, powerFilter);
        powerOn = true;
    }

    // Set up Memory Card logging
    if (Settings.loggingMedia(this)) {
        IntentFilter mediaFilter = new IntentFilter(Intent.ACTION_MEDIA_REMOVED);
        mediaFilter.addAction(Intent.ACTION_MEDIA_BAD_REMOVAL);
        mediaFilter.addAction(Intent.ACTION_MEDIA_MOUNTED);
        mediaFilter.addAction(Intent.ACTION_MEDIA_UNMOUNTED);
        mediaFilter.addAction(Intent.ACTION_MEDIA_SHARED);
        mediaFilter.addDataScheme("file");

        mediaReceiver = new MediaReceiver(this);
        registerReceiver(mediaReceiver, mediaFilter);

        mediaOn = true;
    }

    // Set up GSM logging
    if (Settings.loggingGsm(this)) {
        gsmObserver = new GsmObserver(this);
        telManager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
        telManager.listen(gsmObserver,
                PhoneStateListener.LISTEN_SERVICE_STATE | PhoneStateListener.LISTEN_CELL_LOCATION);
        gsmOn = true;
    }

    // Set up Airplane mode receiver
    if (Settings.loggingAir(this)) {
        IntentFilter airFilter = new IntentFilter(Intent.ACTION_AIRPLANE_MODE_CHANGED);

        airReceiver = new AirplaneReceiver(this);
        registerReceiver(airReceiver, airFilter);
        airOn = true;
    }

    // Set up Photos logging
    if (Settings.loggingPhotos(this)) {
        photoObserver = new PhotoObserver(this, this, handlering);
        photoOn = true;
    }

    // Set up SliceMultimediaFile
    if (Settings.uploadPhotos(this) || Settings.uploadRecords(this)) {
        mediaSlicer = new SliceMultimediaFile(this);
    }

    // Set up ConnectivityReceiver
    mConReceiver = new ConnectivityReceiver(this);
    registerReceiver(mConReceiver, new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION));

    // Ser up CallIntentReceiver
    //outCallReceiver = new CallIntentReceiver();
    //registerReceiver(outCallReceiver, new IntentFilter(KLService.OUTGOING_CALL));
}

From source file:com.android.server.MountService.java

/**
 * Callback from NativeDaemonConnector//from w  w w. j a  va2 s  .  c  o  m
 */
public boolean onEvent(int code, String raw, String[] cooked) {
    if (DEBUG_EVENTS) {
        StringBuilder builder = new StringBuilder();
        builder.append("onEvent::");
        builder.append(" raw= " + raw);
        if (cooked != null) {
            builder.append(" cooked = ");
            for (String str : cooked) {
                builder.append(" " + str);
            }
        }
        Slog.i(TAG, builder.toString());
    }
    if (code == VoldResponseCode.VolumeStateChange) {
        /*
         * One of the volumes we're managing has changed state.
         * Format: "NNN Volume <label> <path> state changed
         * from <old_#> (<old_str>) to <new_#> (<new_str>)"
         */
        notifyVolumeStateChange(cooked[2], cooked[3], Integer.parseInt(cooked[7]),
                Integer.parseInt(cooked[10]));
    } else if (code == VoldResponseCode.VolumeUuidChange) {
        // Format: nnn <label> <path> <uuid>
        final String path = cooked[2];
        final String uuid = (cooked.length > 3) ? cooked[3] : null;

        final StorageVolume vol = mVolumesByPath.get(path);
        if (vol != null) {
            vol.setUuid(uuid);
        }

    } else if (code == VoldResponseCode.VolumeUserLabelChange) {
        // Format: nnn <label> <path> <label>
        final String path = cooked[2];
        final String userLabel = (cooked.length > 3) ? cooked[3] : null;

        final StorageVolume vol = mVolumesByPath.get(path);
        if (vol != null) {
            vol.setUserLabel(userLabel);
        }

    } else if ((code == VoldResponseCode.VolumeDiskInserted) || (code == VoldResponseCode.VolumeDiskRemoved)
            || (code == VoldResponseCode.VolumeBadRemoval)) {
        // FMT: NNN Volume <label> <mountpoint> disk inserted (<major>:<minor>)
        // FMT: NNN Volume <label> <mountpoint> disk removed (<major>:<minor>)
        // FMT: NNN Volume <label> <mountpoint> bad removal (<major>:<minor>)
        String action = null;
        final String label = cooked[2];
        final String path = cooked[3];
        int major = -1;
        int minor = -1;

        try {
            String devComp = cooked[6].substring(1, cooked[6].length() - 1);
            String[] devTok = devComp.split(":");
            major = Integer.parseInt(devTok[0]);
            minor = Integer.parseInt(devTok[1]);
        } catch (Exception ex) {
            Slog.e(TAG, "Failed to parse major/minor", ex);
        }

        final StorageVolume volume;
        final String state;
        synchronized (mVolumesLock) {
            volume = mVolumesByPath.get(path);
            state = mVolumeStates.get(path);
        }

        if (code == VoldResponseCode.VolumeDiskInserted) {
            new Thread("MountService#VolumeDiskInserted") {
                @Override
                public void run() {
                    try {
                        int rc;
                        if ((rc = doMountVolume(path)) != StorageResultCode.OperationSucceeded) {
                            Slog.w(TAG, String.format("Insertion mount failed (%d)", rc));
                        }
                    } catch (Exception ex) {
                        Slog.w(TAG, "Failed to mount media on insertion", ex);
                    }
                }
            }.start();
        } else if (code == VoldResponseCode.VolumeDiskRemoved) {
            /*
             * This event gets trumped if we're already in BAD_REMOVAL state
             */
            if (getVolumeState(path).equals(Environment.MEDIA_BAD_REMOVAL)) {
                return true;
            }
            /* Send the media unmounted event first */
            if (DEBUG_EVENTS)
                Slog.i(TAG, "Sending unmounted event first");
            updatePublicVolumeState(volume, Environment.MEDIA_UNMOUNTED);
            sendStorageIntent(Intent.ACTION_MEDIA_UNMOUNTED, volume, UserHandle.ALL);

            if (DEBUG_EVENTS)
                Slog.i(TAG, "Sending media removed");
            updatePublicVolumeState(volume, Environment.MEDIA_REMOVED);
            action = Intent.ACTION_MEDIA_REMOVED;
        } else if (code == VoldResponseCode.VolumeBadRemoval) {
            if (DEBUG_EVENTS)
                Slog.i(TAG, "Sending unmounted event first");
            /* Send the media unmounted event first */
            updatePublicVolumeState(volume, Environment.MEDIA_UNMOUNTED);
            sendStorageIntent(Intent.ACTION_MEDIA_UNMOUNTED, volume, UserHandle.ALL);

            if (DEBUG_EVENTS)
                Slog.i(TAG, "Sending media bad removal");
            updatePublicVolumeState(volume, Environment.MEDIA_BAD_REMOVAL);
            action = Intent.ACTION_MEDIA_BAD_REMOVAL;
        } else if (code == VoldResponseCode.FstrimCompleted) {
            EventLogTags.writeFstrimFinish(SystemClock.elapsedRealtime());
        } else {
            Slog.e(TAG, String.format("Unknown code {%d}", code));
        }

        if (action != null) {
            sendStorageIntent(action, volume, UserHandle.ALL);
        }
    } else {
        return false;
    }

    return true;
}

From source file:com.android.server.MountService.java

private void notifyVolumeStateChange(String label, String path, int oldState, int newState) {
    final StorageVolume volume;
    final String state;
    synchronized (mVolumesLock) {
        volume = mVolumesByPath.get(path);
        state = getVolumeState(path);//from  ww  w.jav  a  2s .c  om
    }

    if (DEBUG_EVENTS)
        Slog.i(TAG, "notifyVolumeStateChange::" + state);

    String action = null;

    if (oldState == VolumeState.Shared && newState != oldState) {
        if (LOCAL_LOGD)
            Slog.d(TAG, "Sending ACTION_MEDIA_UNSHARED intent");
        sendStorageIntent(Intent.ACTION_MEDIA_UNSHARED, volume, UserHandle.ALL);
    }

    if (newState == VolumeState.Init) {
    } else if (newState == VolumeState.NoMedia) {
        // NoMedia is handled via Disk Remove events
    } else if (newState == VolumeState.Idle) {
        /*
         * Don't notify if we're in BAD_REMOVAL, NOFS, UNMOUNTABLE, or
         * if we're in the process of enabling UMS
         */
        if (!state.equals(Environment.MEDIA_BAD_REMOVAL) && !state.equals(Environment.MEDIA_NOFS)
                && !state.equals(Environment.MEDIA_UNMOUNTABLE) && !getUmsEnabling()) {
            if (DEBUG_EVENTS)
                Slog.i(TAG, "updating volume state for media bad removal nofs and unmountable");
            updatePublicVolumeState(volume, Environment.MEDIA_UNMOUNTED);
            action = Intent.ACTION_MEDIA_UNMOUNTED;
        }
    } else if (newState == VolumeState.Pending) {
    } else if (newState == VolumeState.Checking) {
        if (DEBUG_EVENTS)
            Slog.i(TAG, "updating volume state checking");
        updatePublicVolumeState(volume, Environment.MEDIA_CHECKING);
        action = Intent.ACTION_MEDIA_CHECKING;
    } else if (newState == VolumeState.Mounted) {
        if (DEBUG_EVENTS)
            Slog.i(TAG, "updating volume state mounted");
        updatePublicVolumeState(volume, Environment.MEDIA_MOUNTED);
        action = Intent.ACTION_MEDIA_MOUNTED;
    } else if (newState == VolumeState.Unmounting) {
        action = Intent.ACTION_MEDIA_EJECT;
    } else if (newState == VolumeState.Formatting) {
    } else if (newState == VolumeState.Shared) {
        if (DEBUG_EVENTS)
            Slog.i(TAG, "Updating volume state media mounted");
        /* Send the media unmounted event first */
        updatePublicVolumeState(volume, Environment.MEDIA_UNMOUNTED);
        sendStorageIntent(Intent.ACTION_MEDIA_UNMOUNTED, volume, UserHandle.ALL);

        if (DEBUG_EVENTS)
            Slog.i(TAG, "Updating media shared");
        updatePublicVolumeState(volume, Environment.MEDIA_SHARED);
        action = Intent.ACTION_MEDIA_SHARED;
        if (LOCAL_LOGD)
            Slog.d(TAG, "Sending ACTION_MEDIA_SHARED intent");
    } else if (newState == VolumeState.SharedMnt) {
        Slog.e(TAG, "Live shared mounts not supported yet!");
        return;
    } else {
        Slog.e(TAG, "Unhandled VolumeState {" + newState + "}");
    }

    if (action != null) {
        sendStorageIntent(action, volume, UserHandle.ALL);
    }
}

From source file:com.amaze.filemanager.activities.MainActivity.java

@Override
public void onResume() {
    super.onResume();
    if (materialDialog != null && !materialDialog.isShowing()) {
        materialDialog.show();/*  w ww.ja  v  a  2 s .  c om*/
        materialDialog = null;
    }
    IntentFilter newFilter = new IntentFilter();
    newFilter.addAction(Intent.ACTION_MEDIA_MOUNTED);
    newFilter.addAction(Intent.ACTION_MEDIA_UNMOUNTED);
    newFilter.addDataScheme(ContentResolver.SCHEME_FILE);
    registerReceiver(mainActivityHelper.mNotificationReceiver, newFilter);
    registerReceiver(receiver2, new IntentFilter("general_communications"));
    if (getSupportFragmentManager().findFragmentById(R.id.content_frame).getClass().getName()
            .contains("TabFragment")) {

        floatingActionButton.setVisibility(View.VISIBLE);
        floatingActionButton.showMenuButton(false);
    } else {

        floatingActionButton.setVisibility(View.INVISIBLE);
        floatingActionButton.hideMenuButton(false);
    }
}

From source file:com.filemanager.free.activities.MainActivity.java

@Override
public void onResume() {
    AdWrapper.viewAd(true, mainActivity);
    requestNewInterstitial();/*from  ww  w  . j a  v a2  s  . c  o  m*/
    if (materialDialog != null && !materialDialog.isShowing()) {
        materialDialog.show();
        materialDialog = null;
    }
    IntentFilter newFilter = new IntentFilter();
    newFilter.addAction(Intent.ACTION_MEDIA_MOUNTED);
    newFilter.addAction(Intent.ACTION_MEDIA_UNMOUNTED);
    newFilter.addDataScheme(ContentResolver.SCHEME_FILE);
    registerReceiver(mainActivityHelper.mNotificationReceiver, newFilter);
    registerReceiver(receiver2, new IntentFilter("general_communications"));
    if (getSupportFragmentManager().findFragmentById(R.id.content_frame).getClass().getName()
            .contains("TabFragment")) {

        floatingActionButton.setVisibility(View.VISIBLE);
        floatingActionButton.showMenuButton(false);
    } else {

        floatingActionButton.setVisibility(View.INVISIBLE);
        floatingActionButton.hideMenuButton(false);
    }
    super.onResume();
}

From source file:com.igniva.filemanager.activities.MainActivity.java

@Override
public void onResume() {
    super.onResume();
    if (materialDialog != null && !materialDialog.isShowing()) {
        materialDialog.show();/*from ww w  . j a  va 2 s  .  com*/
        materialDialog = null;
    }
    IntentFilter newFilter = new IntentFilter();
    newFilter.addAction(Intent.ACTION_MEDIA_MOUNTED);
    newFilter.addAction(Intent.ACTION_MEDIA_UNMOUNTED);
    newFilter.addDataScheme(ContentResolver.SCHEME_FILE);
    registerReceiver(mainActivityHelper.mNotificationReceiver, newFilter);
    registerReceiver(receiver2, new IntentFilter("general_communications"));
    if (getSupportFragmentManager().findFragmentById(R.id.content_frame).getClass().getName()
            .contains("TabFragment")) {

        floatingActionButton.setVisibility(View.VISIBLE);
        floatingActionButton.showMenuButton(false);
    } else {

        floatingActionButton.setVisibility(View.INVISIBLE);
        floatingActionButton.hideMenuButton(false);
    }

    // Registering intent filter for OTG
    IntentFilter otgFilter = new IntentFilter();
    otgFilter.addAction(UsbManager.ACTION_USB_DEVICE_ATTACHED);
    otgFilter.addAction(UsbManager.ACTION_USB_DEVICE_DETACHED);
}