Example usage for android.content Intent getBooleanExtra

List of usage examples for android.content Intent getBooleanExtra

Introduction

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

Prototype

public boolean getBooleanExtra(String name, boolean defaultValue) 

Source Link

Document

Retrieve extended data from the intent.

Usage

From source file:com.aimfire.gallery.GalleryActivity.java

/**
 * this activity (GalleryActivity) can receive intent from: 
 * 1. ThumbsFragment - when a thumbnail is selected
 * 2. PhotoProcessor - when a photo is finished processing
 * 3. MovieProcessor - when a movie is finished processing
 * 4. user click a .cvr file from file browser
 * 5. user click link (of amifire-vr scheme) in browser
 * 6. user click link (with our domain name) in mail or other programs (other than browser)
 * //ww w  .j  a v  a2s . c  o  m
 * in the first three cases, the intent we get will have extras EXTRA_PATH and EXTRA_MSG.
 * in the fourth case, we will have intent with getData with path to the .cvr file (or occasionally jpg file).
 * in the last two cases, we will have a link that we need to parse.
 */
private void parseIntent(Intent intent) {
    /*
     * set mIsMyMedia according to intent. we may or may not have EXTRA_MSG
     * passed in. in case we don't have it passed in we will set it to false
     * here by default. it may get overriden after we parsed the intent.
     */
    mIsMyMedia = intent.getBooleanExtra(MainConsts.EXTRA_MSG, false);

    String filePath = null;

    Uri uri = intent.getData();

    if (uri != null) {
        if (uri.getScheme().equalsIgnoreCase("file")) {
            filePath = handleLocalOpen(uri);
        } else if (uri.getScheme().equalsIgnoreCase("https") || uri.getScheme().equalsIgnoreCase("http")
                || uri.getScheme().equalsIgnoreCase("aimfire-vr")) {
            filePath = handleDownload(uri);
        }
    } else {
        filePath = intent.getStringExtra(MainConsts.EXTRA_PATH);
    }

    if (filePath == null) {
        if (BuildConfig.DEBUG)
            Log.e(TAG, "parseIntent: filePath is null");
        return;
    }

    /*
     * update view pager - if file is already in the view pager, this will 
     * updates its view only. if it is not, this will refresh the entire
     * view pager to add it.
     */
    updateViewPager(filePath, -1, -1);
}

From source file:com.sim2dial.dialer.LinphoneActivity.java

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (resultCode == Activity.RESULT_FIRST_USER && requestCode == SETTINGS_ACTIVITY) {
        if (data.getExtras().getBoolean("Exit", false)) {
            exit();//from ww w . j  av  a 2  s.c om
        } else {
            FragmentsAvailable newFragment = (FragmentsAvailable) data.getExtras()
                    .getSerializable("FragmentToDisplay");
            changeCurrentFragment(newFragment, null, true);
            selectMenu(newFragment);
        }
    } else if (requestCode == callActivity) {
        boolean callTransfer = data == null ? false : data.getBooleanExtra("Transfer", false);
        if (LinphoneManager.getLc().getCallsNb() > 0) {
            initInCallMenuLayout(callTransfer);
        } else {
            resetClassicMenuLayoutAndGoBackToCallIfStillRunning();
        }
    } else {
        super.onActivityResult(requestCode, resultCode, data);
    }
}

From source file:co.taqat.call.LinphoneActivity.java

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (resultCode == Activity.RESULT_FIRST_USER && requestCode == SETTINGS_ACTIVITY) {
        if (data.getExtras().getBoolean("Exit", false)) {
            quit();/*from w  w  w .j a va2s . com*/
        } else {
            pendingFragmentTransaction = (FragmentsAvailable) data.getExtras()
                    .getSerializable("FragmentToDisplay");
        }
    } else if (resultCode == Activity.RESULT_FIRST_USER && requestCode == CALL_ACTIVITY) {
        getIntent().putExtra("PreviousActivity", CALL_ACTIVITY);
        callTransfer = data == null ? false : data.getBooleanExtra("Transfer", false);
        boolean chat = data == null ? false : data.getBooleanExtra("chat", false);
        if (chat) {
            pendingFragmentTransaction = FragmentsAvailable.CHAT_LIST;
        }
        if (LinphoneManager.getLc().getCallsNb() > 0) {
            initInCallMenuLayout(callTransfer);
        } else {
            resetClassicMenuLayoutAndGoBackToCallIfStillRunning();
        }
    } else if (requestCode == PERMISSIONS_REQUEST_OVERLAY) {
        if (Compatibility.canDrawOverlays(this)) {
            LinphonePreferences.instance().enableOverlay(true);
        }
    } else {
        super.onActivityResult(requestCode, resultCode, data);
    }
}

From source file:com.brandroidtools.filemanager.activities.NavigationActivity.java

/**
 * {@inheritDoc}//from   w ww.  j  a va  2  s  .c  om
 */
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (data != null) {
        switch (requestCode) {
        case INTENT_REQUEST_BOOKMARK:
            if (resultCode == RESULT_OK) {
                FileSystemObject fso = (FileSystemObject) data.getSerializableExtra(EXTRA_BOOKMARK_SELECTION);
                if (fso != null) {
                    //Open the fso
                    getCurrentNavigationFragment().open(fso);
                }
            }
            break;

        case INTENT_REQUEST_HISTORY:
            if (resultCode == RESULT_OK) {
                //Change current directory
                History history = (History) data.getSerializableExtra(EXTRA_HISTORY_ENTRY_SELECTION);
                navigateToHistory(history);
            } else if (resultCode == RESULT_CANCELED) {
                boolean clear = data.getBooleanExtra(EXTRA_HISTORY_CLEAR, false);
                if (clear) {
                    clearHistory();
                }
            }
            break;

        case INTENT_REQUEST_SEARCH:
            if (resultCode == RESULT_OK) {
                //Change directory?
                FileSystemObject fso = (FileSystemObject) data
                        .getSerializableExtra(EXTRA_SEARCH_ENTRY_SELECTION);
                SearchInfoParcelable searchInfo = data.getParcelableExtra(EXTRA_SEARCH_LAST_SEARCH_DATA);
                if (fso != null) {
                    //Goto to new directory
                    getCurrentNavigationFragment().open(fso, searchInfo);
                }
            } else if (resultCode == RESULT_CANCELED) {
                SearchInfoParcelable searchInfo = data.getParcelableExtra(EXTRA_SEARCH_LAST_SEARCH_DATA);
                if (searchInfo != null && searchInfo.isSuccessNavigation()) {
                    //Navigate to previous history
                    back();
                } else {
                    // I don't know is the search view was changed, so try to do a refresh
                    // of the navigation view
                    getCurrentNavigationFragment().refresh(true);
                }
            }
            break;

        default:
            break;
        }
    }
}

From source file:com.quran.labs.androidquran.service.AudioService.java

/**
 * Called when we receive an Intent. When we receive an intent sent to us
 * via startService(), this is the method that gets called. So here we
 * react appropriately depending on the Intent's action, which specifies
 * what is being requested of us.//from ww  w.j  a  va  2s .  c  om
 */
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
    String action = intent.getAction();

    if (action.equals(ACTION_CONNECT)) {
        if (mState == State.Stopped) {
            processStopRequest();
        } else {
            int sura = -1;
            int ayah = -1;
            int state = AudioUpdateIntent.STOPPED;
            if (mState == State.Paused) {
                state = AudioUpdateIntent.PAUSED;
            } else if (mState != State.Stopped) {
                state = AudioUpdateIntent.PLAYING;
            }

            if (mState != State.Stopped) {
                if (mAudioRequest != null) {
                    sura = mAudioRequest.getCurrentSura();
                    ayah = mAudioRequest.getCurrentAyah();
                }
            }

            Intent updateIntent = new Intent(AudioUpdateIntent.INTENT_NAME);
            updateIntent.putExtra(AudioUpdateIntent.STATUS, state);
            updateIntent.putExtra(AudioUpdateIntent.SURA, sura);
            updateIntent.putExtra(AudioUpdateIntent.AYAH, ayah);
            mBroadcastManager.sendBroadcast(updateIntent);
        }
    } else if (action.equals(ACTION_PLAYBACK)) {
        Serializable playInfo = intent.getSerializableExtra(EXTRA_PLAY_INFO);
        if (playInfo != null && playInfo instanceof AudioRequest) {
            if (mState == State.Stopped || !intent.getBooleanExtra(EXTRA_IGNORE_IF_PLAYING, false)) {
                mAudioRequest = (AudioRequest) playInfo;
            }
        }

        if (intent.getBooleanExtra(EXTRA_STOP_IF_PLAYING, false)) {
            if (mPlayer != null) {
                mPlayer.stop();
            }
            mState = State.Stopped;
        }

        processTogglePlaybackRequest();
    } else if (action.equals(ACTION_PLAY)) {
        processPlayRequest();
    } else if (action.equals(ACTION_PAUSE)) {
        processPauseRequest();
    } else if (action.equals(ACTION_SKIP)) {
        processSkipRequest();
    } else if (action.equals(ACTION_STOP)) {
        processStopRequest();
    } else if (action.equals(ACTION_REWIND)) {
        processRewindRequest();
    } else if (action.equals(ACTION_UPDATE_REPEAT)) {
        Serializable repeatInfo = intent.getSerializableExtra(EXTRA_REPEAT_INFO);
        if (repeatInfo != null && mAudioRequest != null) {
            if (repeatInfo instanceof RepeatInfo) {
                mAudioRequest.setRepeatInfo((RepeatInfo) repeatInfo);
            }
        }
    }

    return START_NOT_STICKY; // Means we started the service, but don't want
    // it to restart in case it's killed.
}

From source file:eu.faircode.adblocker.ServiceSinkhole.java

private void set(Intent intent) {
    // Get arguments
    int uid = intent.getIntExtra(EXTRA_UID, 0);
    String network = intent.getStringExtra(EXTRA_NETWORK);
    String pkg = intent.getStringExtra(EXTRA_PACKAGE);
    boolean blocked = intent.getBooleanExtra(EXTRA_BLOCKED, false);
    Log.i(TAG, "Set " + pkg + " " + network + "=" + blocked);

    // Get defaults
    SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(ServiceSinkhole.this);
    boolean default_wifi = settings.getBoolean("whitelist_wifi", true);
    boolean default_other = settings.getBoolean("whitelist_other", true);

    // Update setting
    SharedPreferences prefs = getSharedPreferences(network, Context.MODE_PRIVATE);
    if (blocked == ("wifi".equals(network) ? default_wifi : default_other))
        prefs.edit().remove(pkg).apply();
    else// w  w  w  .j  a v a2s.  c o  m
        prefs.edit().putBoolean(pkg, blocked).apply();

    // Apply rules
    ServiceSinkhole.reload("notification", ServiceSinkhole.this);

    // Update notification
    Receiver.notifyNewApplication(uid, ServiceSinkhole.this);

    // Update UI
    Intent ruleset = new Intent(ActivityMain.ACTION_RULES_CHANGED);
    LocalBroadcastManager.getInstance(ServiceSinkhole.this).sendBroadcast(ruleset);
}

From source file:com.nachiket.titan.LibraryActivity.java

/**
 * Creates a context menu for an adapter row.
 *
 * @param menu The menu to create./*from  w  w w .j a v a 2  s .  c om*/
 * @param rowData Data for the adapter row.
 */
public void onCreateContextMenu(ContextMenu menu, Intent rowData) {
    if (rowData.getLongExtra(LibraryAdapter.DATA_ID, LibraryAdapter.INVALID_ID) == LibraryAdapter.HEADER_ID) {
        menu.setHeaderTitle(getString(R.string.all_songs));
        menu.add(0, MENU_PLAY_ALL, 0, R.string.play_all).setIntent(rowData);
        menu.add(0, MENU_ENQUEUE_ALL, 0, R.string.enqueue_all).setIntent(rowData);
        menu.addSubMenu(0, MENU_ADD_TO_PLAYLIST, 0, R.string.add_to_playlist).getItem().setIntent(rowData);
    } else {
        int type = rowData.getIntExtra(LibraryAdapter.DATA_TYPE, MediaUtils.TYPE_INVALID);
        boolean isAllAdapter = type <= MediaUtils.TYPE_SONG;

        menu.setHeaderTitle(rowData.getStringExtra(LibraryAdapter.DATA_TITLE));
        menu.add(0, MENU_PLAY, 0, R.string.play).setIntent(rowData);
        if (isAllAdapter)
            menu.add(0, MENU_PLAY_ALL, 0, R.string.play_all).setIntent(rowData);
        menu.add(0, MENU_ENQUEUE, 0, R.string.enqueue).setIntent(rowData);
        if (isAllAdapter)
            menu.add(0, MENU_ENQUEUE_ALL, 0, R.string.enqueue_all).setIntent(rowData);
        if (type == MediaUtils.TYPE_PLAYLIST) {
            menu.add(0, MENU_RENAME_PLAYLIST, 0, R.string.rename).setIntent(rowData);
            menu.add(0, MENU_EXPAND, 0, R.string.edit).setIntent(rowData);
        } else if (rowData.getBooleanExtra(LibraryAdapter.DATA_EXPANDABLE, false)) {
            menu.add(0, MENU_EXPAND, 0, R.string.expand).setIntent(rowData);
        }
        if (type == MediaUtils.TYPE_ALBUM || type == MediaUtils.TYPE_SONG)
            menu.add(0, MENU_MORE_FROM_ARTIST, 0, R.string.more_from_artist).setIntent(rowData);
        if (type == MediaUtils.TYPE_SONG)
            menu.add(0, MENU_MORE_FROM_ALBUM, 0, R.string.more_from_album).setIntent(rowData);
        menu.addSubMenu(0, MENU_ADD_TO_PLAYLIST, 0, R.string.add_to_playlist).getItem().setIntent(rowData);
        menu.add(0, MENU_DELETE, 0, R.string.delete).setIntent(rowData);
    }
}

From source file:info.snowhow.plugin.RecorderService.java

@Override
public int onStartCommand(Intent intent, int flags, int startId) {
    Log.i(LOG_TAG, "Received start id " + startId + ": " + intent);
    if (!locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)) {
        showNoGPSAlert();//from  ww  w.j a v a  2 s . c  om
    }
    runningID = startId;
    // We want this service to continue running until it is explicitly
    // stopped, so return sticky.

    if (intent == null) {
        tf = sharedPref.getString("runningTrackFile", "");
        Log.w(LOG_TAG, "Intent is null, trying to continue to write to file " + tf + " lm " + locationManager);
        minimumPrecision = sharedPref.getFloat("runningPrecision", 0);
        distanceChange = sharedPref.getLong("runningDistanceChange", MINIMUM_DISTANCE_CHANGE_FOR_UPDATES);
        updateTime = sharedPref.getLong("runningUpdateTime", MINIMUM_TIME_BETWEEN_UPDATES);
        updateTimeFast = sharedPref.getLong("runningUpdateTimeFast", MINIMUM_TIME_BETWEEN_UPDATES_FAST);
        speedLimit = sharedPref.getLong("runningSpeedLimit", SPEED_LIMIT);
        adaptiveRecording = sharedPref.getBoolean("adaptiveRecording", false);
        int count = sharedPref.getInt("count", 0);
        if (count > 0) {
            firstPoint = false;
        }
        if (tf == null || tf == "") {
            Log.e(LOG_TAG, "No trackfile found ... exit clean here");
            cleanUp();
            return START_NOT_STICKY;
        }
    } else {
        tf = intent.getStringExtra("fileName");
        Log.d(LOG_TAG, "FILENAME for recording is " + tf);
        minimumPrecision = intent.getFloatExtra("precision", 0);
        distanceChange = intent.getLongExtra("distance_change", MINIMUM_DISTANCE_CHANGE_FOR_UPDATES);
        updateTime = intent.getLongExtra("update_time", MINIMUM_TIME_BETWEEN_UPDATES);
        updateTimeFast = intent.getLongExtra("update_time_fast", MINIMUM_TIME_BETWEEN_UPDATES_FAST);
        speedLimit = intent.getLongExtra("speed_limit", SPEED_LIMIT);
        adaptiveRecording = intent.getBooleanExtra("adaptiveRecording", false);
        editor.putString("runningTrackFile", tf);
        editor.putFloat("runningPrecision", minimumPrecision);
        editor.putLong("runningDistanceChange", distanceChange);
        editor.putLong("runningUpdateTime", updateTime);
        editor.putLong("runningUpdateTimeFast", updateTimeFast);
        editor.putLong("runningSpeedLimit", speedLimit);
        editor.putBoolean("adaptiveRecording", adaptiveRecording);
        editor.commit();
    }

    Intent cordovaMainIntent;
    try {
        PackageManager packageManager = this.getPackageManager();
        cordovaMainIntent = packageManager.getLaunchIntentForPackage(this.getPackageName());
        Log.d(LOG_TAG, "got cordovaMainIntent " + cordovaMainIntent);
        if (cordovaMainIntent == null) {
            throw new PackageManager.NameNotFoundException();
        }
    } catch (PackageManager.NameNotFoundException e) {
        cordovaMainIntent = new Intent();
    }
    PendingIntent pend = PendingIntent.getActivity(this, 0, cordovaMainIntent, 0);
    PendingIntent pendingIntent = PendingIntent.getBroadcast(this, 0, new Intent(ifString), 0);
    NotificationCompat.Action stop = new NotificationCompat.Action.Builder(android.R.drawable.ic_delete,
            "Stop recording", pendingIntent).build();
    note = new NotificationCompat.Builder(this).setContentTitle(applicationName + " GPS tracking")
            .setSmallIcon(android.R.drawable.ic_menu_mylocation).setOngoing(true).setContentIntent(pend)
            .setContentText("No location yet.");
    note.addAction(stop);

    nm = (NotificationManager) getSystemService(Activity.NOTIFICATION_SERVICE);
    nm.notify(0, note.build());

    recording = true;
    Log.d(LOG_TAG, "recording in handleIntent");
    try { // create directory first, if it does not exist
        File trackFile = new File(tf).getParentFile();
        if (!trackFile.exists()) {
            trackFile.mkdirs();
            Log.d(LOG_TAG, "done creating path for trackfile: " + trackFile);
        }
        Log.d(LOG_TAG, "going to create RandomAccessFile " + tf);
        myWriter = new RandomAccessFile(tf, "rw");
        if (intent != null) { // start new file
            // myWriter.setLength(0);    // delete all contents from file
            String trackName = intent.getStringExtra("trackName");
            String trackHead = initTrack(trackName).toString();
            myWriter.write(trackHead.getBytes());
            // we want to write JSON manually for streamed writing
            myWriter.seek(myWriter.length() - 1);
            myWriter.write(",\"coordinates\":[]}".getBytes());
        }
    } catch (IOException e) {
        Log.d(LOG_TAG, "io error. cannot write to file " + tf);
    }
    locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, updateTime, distanceChange, mgpsll);
    if (locationManager.getAllProviders().contains(LocationManager.NETWORK_PROVIDER)) {
        locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, updateTime, distanceChange,
                mnetll);
    }
    return START_STICKY;
}

From source file:com.fsck.k9.activity.Accounts.java

@Override
public void onCreate(Bundle icicle) {

    super.onCreate(icicle);

    if (!K9.isHideSpecialAccounts()) {
        createSpecialAccounts();// w ww.  ja v a2  s .  c  om
    }

    Account[] accounts = Preferences.getPreferences(this).getAccounts();
    Intent intent = getIntent();
    //onNewIntent(intent);

    // see if we should show the welcome message
    if (ACTION_IMPORT_SETTINGS.equals(intent.getAction())) {
        onImport();
    } else if (accounts.length < 1) {
        WelcomeMessage.showWelcomeMessage(this);
        finish();
        return;
    }

    if (UpgradeDatabases.actionUpgradeDatabases(this, intent)) {
        finish();
        return;
    }

    boolean startup = intent.getBooleanExtra(EXTRA_STARTUP, true);
    if (startup && K9.startIntegratedInbox() && !K9.isHideSpecialAccounts()) {
        onOpenAccount(mUnifiedInboxAccount);
        finish();
        return;
    } else if (startup && accounts.length == 1 && onOpenAccount(accounts[0])) {
        finish();
        return;
    }

    mActionBar = getSupportActionBar();
    initializeActionBar();
    //setContentView(R.layout.accounts);
    ListView listView = getListView();
    listView.setOnItemClickListener(this);
    listView.setItemsCanFocus(false);
    listView.setScrollingCacheEnabled(false);
    registerForContextMenu(listView);

    if (icicle != null && icicle.containsKey(SELECTED_CONTEXT_ACCOUNT)) {
        String accountUuid = icicle.getString("selectedContextAccount");
        mSelectedContextAccount = Preferences.getPreferences(this).getAccount(accountUuid);
    }

    restoreAccountStats(icicle);
    mHandler.setViewTitle();

    // Handle activity restarts because of a configuration change (e.g. rotating the screen)
    mNonConfigurationInstance = (NonConfigurationInstance) getLastCustomNonConfigurationInstance();
    if (mNonConfigurationInstance != null) {
        mNonConfigurationInstance.restore(this);
    }

    ChangeLog cl = new ChangeLog(this);
    if (cl.isFirstRun()) {
        cl.getLogDialog().show();
    }
}

From source file:com.owncloud.android.services.OperationsService.java

/**
 * Creates a new operation, as described by operationIntent.
 * // w  ww.  j a v  a2  s .c  o m
 * TODO - move to ServiceHandler (probably)
 * 
 * @param operationIntent       Intent describing a new operation to queue and execute.
 * @return                      Pair with the new operation object and the information about its
 *                              target server.
 */
private Pair<Target, RemoteOperation> newOperation(Intent operationIntent) {
    RemoteOperation operation = null;
    Target target = null;
    try {
        if (!operationIntent.hasExtra(EXTRA_ACCOUNT) && !operationIntent.hasExtra(EXTRA_SERVER_URL)) {
            Log_OC.e(TAG, "Not enough information provided in intent");

        } else {
            Account account = operationIntent.getParcelableExtra(EXTRA_ACCOUNT);
            String serverUrl = operationIntent.getStringExtra(EXTRA_SERVER_URL);
            String cookie = operationIntent.getStringExtra(EXTRA_COOKIE);
            target = new Target(account, (serverUrl == null) ? null : Uri.parse(serverUrl), cookie);

            String action = operationIntent.getAction();
            if (action.equals(ACTION_CREATE_SHARE_VIA_LINK)) { // Create public share via link

                String remotePath = operationIntent.getStringExtra(EXTRA_REMOTE_PATH);

                if (remotePath != null && remotePath.length() > 0) {

                    operation = new CreateShareViaLinkOperation(remotePath);

                    String name = operationIntent.getStringExtra(EXTRA_SHARE_NAME);
                    ((CreateShareViaLinkOperation) operation).setName(name);

                    String password = operationIntent.getStringExtra(EXTRA_SHARE_PASSWORD);
                    ((CreateShareViaLinkOperation) operation).setPassword(password);

                    long expirationDateMillis = operationIntent
                            .getLongExtra(EXTRA_SHARE_EXPIRATION_DATE_IN_MILLIS, 0);

                    ((CreateShareViaLinkOperation) operation).setExpirationDateInMillis(expirationDateMillis);

                    Boolean uploadToFolderPermission = operationIntent
                            .getBooleanExtra(EXTRA_SHARE_PUBLIC_UPLOAD, false);

                    ((CreateShareViaLinkOperation) operation).setPublicUpload(uploadToFolderPermission);

                    int permissions = operationIntent.getIntExtra(EXTRA_SHARE_PERMISSIONS,
                            OCShare.DEFAULT_PERMISSION);

                    ((CreateShareViaLinkOperation) operation).setPermissions(permissions);
                }

            } else if (ACTION_UPDATE_SHARE_VIA_LINK.equals(action)) {
                long shareId = operationIntent.getLongExtra(EXTRA_SHARE_ID, -1);
                operation = new UpdateShareViaLinkOperation(shareId);

                String name = operationIntent.getStringExtra(EXTRA_SHARE_NAME);
                ((UpdateShareViaLinkOperation) operation).setName(name);

                String password = operationIntent.getStringExtra(EXTRA_SHARE_PASSWORD);
                ((UpdateShareViaLinkOperation) operation).setPassword(password);

                long expirationDate = operationIntent.getLongExtra(EXTRA_SHARE_EXPIRATION_DATE_IN_MILLIS, 0);
                ((UpdateShareViaLinkOperation) operation).setExpirationDate(expirationDate);

                if (operationIntent.hasExtra(EXTRA_SHARE_PUBLIC_UPLOAD)) {
                    ((UpdateShareViaLinkOperation) operation)
                            .setPublicUpload(operationIntent.getBooleanExtra(EXTRA_SHARE_PUBLIC_UPLOAD, false));
                }

                if (operationIntent.hasExtra(EXTRA_SHARE_PERMISSIONS)) {
                    ((UpdateShareViaLinkOperation) operation).setPermissions(
                            operationIntent.getIntExtra(EXTRA_SHARE_PERMISSIONS, OCShare.DEFAULT_PERMISSION));
                }

            } else if (ACTION_UPDATE_SHARE_WITH_SHAREE.equals(action)) {
                // Update private share, only permissions
                long shareId = operationIntent.getLongExtra(EXTRA_SHARE_ID, -1);
                operation = new UpdateSharePermissionsOperation(shareId);
                int permissions = operationIntent.getIntExtra(EXTRA_SHARE_PERMISSIONS, 1);
                ((UpdateSharePermissionsOperation) operation).setPermissions(permissions);

            } else if (action.equals(ACTION_CREATE_SHARE_WITH_SHAREE)) {
                // Create private share with user or group
                String remotePath = operationIntent.getStringExtra(EXTRA_REMOTE_PATH);
                String shareeName = operationIntent.getStringExtra(EXTRA_SHARE_WITH);
                ShareType shareType = (ShareType) operationIntent.getSerializableExtra(EXTRA_SHARE_TYPE);
                int permissions = operationIntent.getIntExtra(EXTRA_SHARE_PERMISSIONS, -1);
                if (remotePath.length() > 0) {
                    operation = new CreateShareWithShareeOperation(remotePath, shareeName, shareType,
                            permissions);
                }

            } else if (action.equals(ACTION_UNSHARE)) { // Unshare file
                long shareId = operationIntent.getLongExtra(EXTRA_SHARE_ID, -1);
                operation = new RemoveShareOperation(shareId);

            } else if (action.equals(ACTION_GET_SERVER_INFO)) {
                // check OC server and get basic information from it
                operation = new GetServerInfoOperation(serverUrl, OperationsService.this);

            } else if (action.equals(ACTION_OAUTH2_GET_ACCESS_TOKEN)) {
                // CREATE ACCESS TOKEN to the OAuth server
                String code = operationIntent.getStringExtra(EXTRA_OAUTH2_AUTHORIZATION_CODE);

                OAuth2Provider oAuth2Provider = OAuth2ProvidersRegistry.getInstance().getProvider();
                OAuth2RequestBuilder builder = oAuth2Provider.getOperationBuilder();
                builder.setGrantType(OAuth2GrantType.AUTHORIZATION_CODE);
                builder.setRequest(OAuth2RequestBuilder.OAuthRequest.CREATE_ACCESS_TOKEN);
                builder.setAuthorizationCode(code);

                operation = builder.buildOperation();

            } else if (action.equals(ACTION_GET_USER_NAME)) {
                // Get User Name
                operation = new GetRemoteUserInfoOperation();

            } else if (action.equals(ACTION_RENAME)) {
                // Rename file or folder
                String remotePath = operationIntent.getStringExtra(EXTRA_REMOTE_PATH);
                String newName = operationIntent.getStringExtra(EXTRA_NEWNAME);
                operation = new RenameFileOperation(remotePath, newName);

            } else if (action.equals(ACTION_REMOVE)) {
                // Remove file or folder
                String remotePath = operationIntent.getStringExtra(EXTRA_REMOTE_PATH);
                boolean onlyLocalCopy = operationIntent.getBooleanExtra(EXTRA_REMOVE_ONLY_LOCAL, false);
                operation = new RemoveFileOperation(remotePath, onlyLocalCopy);

            } else if (action.equals(ACTION_CREATE_FOLDER)) {
                // Create Folder
                String remotePath = operationIntent.getStringExtra(EXTRA_REMOTE_PATH);
                boolean createFullPath = operationIntent.getBooleanExtra(EXTRA_CREATE_FULL_PATH, true);
                operation = new CreateFolderOperation(remotePath, createFullPath);

            } else if (action.equals(ACTION_SYNC_FILE)) {
                // Sync file
                String remotePath = operationIntent.getStringExtra(EXTRA_REMOTE_PATH);
                operation = new SynchronizeFileOperation(remotePath, account, getApplicationContext());

            } else if (action.equals(ACTION_SYNC_FOLDER)) {
                // Sync folder (all its descendant files are sync'ed)
                String remotePath = operationIntent.getStringExtra(EXTRA_REMOTE_PATH);
                boolean pushOnly = operationIntent.getBooleanExtra(EXTRA_PUSH_ONLY, false);
                boolean syncContentOfRegularFiles = operationIntent.getBooleanExtra(EXTRA_SYNC_REGULAR_FILES,
                        false);
                operation = new SynchronizeFolderOperation(this, // TODO remove this dependency from construction time
                        remotePath, account, System.currentTimeMillis(), // TODO remove this dependency from construction time
                        pushOnly, false, syncContentOfRegularFiles);

            } else if (action.equals(ACTION_MOVE_FILE)) {
                // Move file/folder
                String remotePath = operationIntent.getStringExtra(EXTRA_REMOTE_PATH);
                String newParentPath = operationIntent.getStringExtra(EXTRA_NEW_PARENT_PATH);
                operation = new MoveFileOperation(remotePath, newParentPath);

            } else if (action.equals(ACTION_COPY_FILE)) {
                // Copy file/folder
                String remotePath = operationIntent.getStringExtra(EXTRA_REMOTE_PATH);
                String newParentPath = operationIntent.getStringExtra(EXTRA_NEW_PARENT_PATH);
                operation = new CopyFileOperation(remotePath, newParentPath, account);

            } else if (action.equals(ACTION_CHECK_CURRENT_CREDENTIALS)) {
                // Check validity of currently stored credentials for a given account
                operation = new CheckCurrentCredentialsOperation(account);

            }
        }

    } catch (IllegalArgumentException e) {
        Log_OC.e(TAG, "Bad information provided in intent: " + e.getMessage());
        operation = null;
    }

    if (operation != null) {
        return new Pair<>(target, operation);
    } else {
        return null;
    }
}