Example usage for android.content Intent getIntExtra

List of usage examples for android.content Intent getIntExtra

Introduction

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

Prototype

public int getIntExtra(String name, int defaultValue) 

Source Link

Document

Retrieve extended data from the intent.

Usage

From source file:at.jclehner.rxdroid.DrugEditFragment.java

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

    Intent intent = getActivity().getIntent();
    String action = intent.getAction();

    Drug drug = null;/*from   w w  w. j  a va  2 s .co m*/

    mWrapper = new DrugWrapper();
    mFocusOnCurrentSupply = false;

    if (Intent.ACTION_EDIT.equals(action)) {
        final int drugId = intent.getIntExtra(DrugEditActivity2.EXTRA_DRUG_ID, -1);
        if (drugId == -1)
            throw new IllegalStateException("ACTION_EDIT requires EXTRA_DRUG_ID");

        drug = Drug.get(drugId);

        if (LOGV)
            Util.dumpObjectMembers(TAG, Log.VERBOSE, drug, "drug");

        mWrapper.set(drug);
        mDrugHash = drug.hashCode();
        mIsEditing = true;

        if (intent.getBooleanExtra(DrugEditActivity2.EXTRA_FOCUS_ON_CURRENT_SUPPLY, false))
            mFocusOnCurrentSupply = true;

        setActivityTitle(drug.getName());
    } else if (Intent.ACTION_INSERT.equals(action)) {
        mIsEditing = false;
        mWrapper.set(new Drug());
        setActivityTitle(R.string._title_new_drug);
    } else
        throw new IllegalArgumentException("Unhandled action " + action);

    if (mWrapper.refillSize == 0)
        mWrapper.currentSupply = Fraction.ZERO;

    OTPM.mapToPreferenceHierarchy(getPreferenceScreen(), mWrapper);
    getPreferenceScreen().setOnPreferenceChangeListener(mListener);

    if (!mIsEditing) {
        final Preference p = findPreference("active");
        if (p != null)
            p.setEnabled(false);
    }

    if (mWrapper.refillSize == 0) {
        final Preference p = findPreference("currentSupply");
        if (p != null)
            p.setEnabled(false);
    }

    if (mFocusOnCurrentSupply) {
        Log.i(TAG, "Will focus on current supply preference");
        performPreferenceClick("currentSupply");
    }

    getActivity().supportInvalidateOptionsMenu();
}

From source file:ch.uzh.supersede.feedbacklibrary.FeedbackActivity.java

@Override
@SuppressWarnings("unchecked")
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    if (resultCode == Activity.RESULT_OK) {
        if (requestCode == REQUEST_PHOTO) {
            onSelectFromGalleryResult(data);
        } else if (requestCode == REQUEST_CAMERA) {
        } else if (requestCode == REQUEST_ANNOTATE && data != null) {
            // If mechanismViewId == -1, an error occurred
            int mechanismViewId = data.getIntExtra(Utils.EXTRA_KEY_MECHANISM_VIEW_ID, -1);
            if (mechanismViewId != -1) {
                ScreenshotMechanismView screenshotMechanismView = (ScreenshotMechanismView) allMechanismViews
                        .get(mechanismViewId);

                // Sticker annotations
                if (data.getBooleanExtra(Utils.EXTRA_KEY_HAS_STICKER_ANNOTATIONS, false)) {
                    screenshotMechanismView.setAllStickerAnnotations((HashMap<Integer, String>) data
                            .getSerializableExtra(Utils.EXTRA_KEY_ALL_STICKER_ANNOTATIONS));
                }/* w  ww .j  a  va2  s.  c  o m*/
                // Text annotations
                if (data.getBooleanExtra(Utils.EXTRA_KEY_HAS_TEXT_ANNOTATIONS, false)) {
                    screenshotMechanismView.setAllTextAnnotations((HashMap<Integer, String>) data
                            .getSerializableExtra(Utils.EXTRA_KEY_ALL_TEXT_ANNOTATIONS));
                }

                // Annotated image with stickers
                String tempPathWithStickers = data
                        .getStringExtra(Utils.EXTRA_KEY_ANNOTATED_IMAGE_PATH_WITH_STICKERS) + "/"
                        + mechanismViewId + ANNOTATED_IMAGE_NAME_WITH_STICKERS;
                screenshotMechanismView.setAnnotatedImagePath(tempPathWithStickers);
                screenshotMechanismView.setPicturePath(tempPathWithStickers);
                Bitmap annotatedBitmap = Utils.loadImageFromStorage(tempPathWithStickers);
                if (annotatedBitmap != null) {
                    screenshotMechanismView.setPictureBitmap(annotatedBitmap);
                    screenshotMechanismView.getScreenShotPreviewImageView().setImageBitmap(annotatedBitmap);
                }

                // Annotated image without stickers
                if (data.getStringExtra(Utils.EXTRA_KEY_ANNOTATED_IMAGE_PATH_WITHOUT_STICKERS) == null) {
                    screenshotMechanismView.setPicturePathWithoutStickers(null);
                } else {
                    String tempPathWithoutStickers = data
                            .getStringExtra(Utils.EXTRA_KEY_ANNOTATED_IMAGE_PATH_WITHOUT_STICKERS) + "/"
                            + mechanismViewId + ANNOTATED_IMAGE_NAME_WITHOUT_STICKERS;
                    screenshotMechanismView.setPicturePathWithoutStickers(tempPathWithoutStickers);
                }
            } else {
                Log.e(TAG, "Failed to annotate the image. No mechanismViewID provided");
            }
        }
    }
}

From source file:com.devpaul.filepickerlibrary.FilePickerActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mContext = this;

    //get the theme type for this activity
    themeType = (ThemeType) getIntent().getSerializableExtra(THEME_TYPE);
    if (themeType == null) {
        themeType = ThemeType.ACTIVITY;/*from  w ww .  jav a2 s  .  c o  m*/
    }

    setThemeType(themeType);

    areButtonsShowing = false;

    try {
        getActionBar().setDisplayHomeAsUpEnabled(true);
    } catch (NullPointerException e) {
        e.printStackTrace();
    }

    //set up the mime type for the file.
    Object rawMimeTypeParameter = getIntent().getExtras().get(MIME_TYPE);
    if (rawMimeTypeParameter instanceof String) {
        mimeType = (String) rawMimeTypeParameter;
    } else if (rawMimeTypeParameter instanceof FileType) {
        mimeType = ((FileType) rawMimeTypeParameter).getMimeType();
    } else {
        mimeType = null;
    }

    //set up the animations
    setUpAnimations();

    Intent givenIntent = getIntent();

    //get the scope type and request code. Defaults are all files and request of a directory
    //path.
    scopeType = (FileScopeType) givenIntent.getSerializableExtra(SCOPE_TYPE);
    if (scopeType == null) {
        //set default if it is null
        scopeType = FileScopeType.ALL;
    }
    requestCode = givenIntent.getIntExtra(REQUEST_CODE, REQUEST_DIRECTORY);

    colorId = givenIntent.getIntExtra(INTENT_EXTRA_COLOR_ID, android.R.color.holo_blue_light);
    drawableId = givenIntent.getIntExtra(INTENT_EXTRA_DRAWABLE_ID, -1);
    fabColorId = givenIntent.getIntExtra(INTENT_EXTRA_FAB_COLOR_ID, -1);

    setContentView(R.layout.file_picker_activity_layout);

    listView = (ListView) findViewById(android.R.id.list);
    listView.setOnScrollListener(new AbsListView.OnScrollListener() {
        @Override
        public void onScrollStateChanged(AbsListView view, int scrollState) {
        }

        @Override
        public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
            if (areButtonsShowing) {
                if (Math.abs(firstVisibleItem - mLastFirstVisibleItem) >= 3) {
                    hideButtons();
                    adapter.setSelectedPosition(-1);
                    mLastFirstVisibleItem = firstVisibleItem;
                } else if (firstVisibleItem > adapter.getSelectedPosition()) {
                    hideButtons();
                    adapter.setSelectedPosition(-1);
                }
            } else {
                mLastFirstVisibleItem = firstVisibleItem;
            }

        }
    });

    listHeaderView = getLayoutInflater().inflate(R.layout.file_list_header_view, null);
    listHeaderView.setFocusable(false);
    listHeaderView.setClickable(false);
    listHeaderView.setOnClickListener(null);
    listHeaderView.setActivated(false);

    initializeViews();

    //drawable has not been set so set the color.
    setHeaderBackground(colorId, drawableId);

    //check for proper permissions.
    if (Build.VERSION.SDK_INT == Build.VERSION_CODES.M) {
        int permissionCheck = ContextCompat.checkSelfPermission(this,
                Manifest.permission.READ_EXTERNAL_STORAGE);
        if (permissionCheck != PackageManager.PERMISSION_GRANTED) {
            if (ActivityCompat.shouldShowRequestPermissionRationale(this,
                    Manifest.permission.READ_EXTERNAL_STORAGE)) {
                //Show permission rationale.
                new MaterialDialog.Builder(FilePickerActivity.this)
                        .title(R.string.file_picker_permission_rationale_dialog_title)
                        .content(R.string.file_picker_permission_rationale_dialog_content)
                        .positiveText(R.string.file_picker_ok).negativeText(R.string.file_picker_cancel)
                        .callback(new MaterialDialog.ButtonCallback() {
                            @Override
                            public void onPositive(MaterialDialog dialog) {
                                ActivityCompat.requestPermissions(FilePickerActivity.this,
                                        new String[] { Manifest.permission.READ_EXTERNAL_STORAGE,
                                                Manifest.permission.WRITE_EXTERNAL_STORAGE },
                                        REQUEST_FOR_READ_EXTERNAL_STORAGE);
                            }

                            @Override
                            public void onNegative(MaterialDialog dialog) {
                                setResult(RESULT_CANCELED);
                                finish();
                            }
                        }).show();
            } else {
                ActivityCompat.requestPermissions(this,
                        new String[] { Manifest.permission.READ_EXTERNAL_STORAGE,
                                Manifest.permission.WRITE_EXTERNAL_STORAGE },
                        REQUEST_FOR_READ_EXTERNAL_STORAGE);
            }
        } else {
            init();
        }
    } else {
        init();
    }
}

From source file:au.org.ala.fielddata.mobile.CollectSurveyData.java

/**
 * Callback made to this activity after the camera, gallery or map activity
 * has finished.//from   w w w  . j av a2  s  .com
 */
protected void onActivityResult(int requestCode, int resultCode, Intent data) {

    if (requestCode == SELECT_LOCATION_REQUEST) {
        if (resultCode == RESULT_OK) {
            Location location = (Location) data.getExtras().get(LocationSelectionActivity.LOCATION_BUNDLE_KEY);
            surveyViewModel.setLocation(location);
        }
    } else if (requestCode == SELECT_POLYGON_LOCATION_REQUEST) {
        if (resultCode == RESULT_OK) {

            WayPoints result = (WayPoints) data.getExtras().get(WayPointActivity.WAY_POINTS_KEY);
            result.setPhotoPointAttribute(data.getIntExtra(WayPointActivity.ATTRIBUTE_ID_KEY, -1));
            surveyViewModel.setWayPoints(result);
        }
    } else if (requestCode == TAKE_PHOTO_REQUEST) {
        if (resultCode == RESULT_OK) {
            surveyViewModel.persistTempValue();
        } else {
            surveyViewModel.clearTempValue();
        }
    } else if (requestCode == SELECT_FROM_GALLERY_REQUEST) {
        TempValue value = surveyViewModel.clearTempValue();
        if (resultCode == RESULT_OK) {
            Uri selected = data.getData();
            if (selected != null) {
                surveyViewModel.setValue(value.getAttribute(), selected.toString());
            } else {
                Log.e("CollectSurveyData", "Null data returned from gallery intent!" + data);
            }
        }
    }
}

From source file:com.mobilesolutionworks.android.httpcache.WorksHttpCacheService.java

protected void refreshData(Intent intent) {
    // rebuild into hierarchical uri
    String local = intent.getStringExtra("local");
    String remote = intent.getStringExtra("remote");

    if (mQueues.contains(local)) {
        return;/*from   www  . j  a v  a  2  s. c  o  m*/
    }

    mQueues.add(local);

    String _method = intent.getStringExtra("method");
    WorksHttpRequest.Method method = WorksHttpRequest.Method.GET;
    if ("POST".equals(_method)) {
        method = WorksHttpRequest.Method.POST;
    }

    WorksHttpRequest config = new WorksHttpRequest();
    config.method = method;
    config.url = remote;

    Bundle params = intent.getBundleExtra("params");
    if (params != null) {
        for (String key : params.keySet()) {
            String value = params.getString(key);
            if (!TextUtils.isEmpty(value)) {
                config.setPostParam(key, value);
            }
        }
    }

    int cache = intent.getIntExtra("cache", 0);
    if (cache == 0) {
        cache = 60;
    }

    cache *= 1000;

    int timeout = intent.getIntExtra("timeout", 0);
    if (timeout == 0) {
        timeout = 10;
    }
    timeout *= 1000;

    WorksHttpFutureTask<String> task = getSaveTask(local, cache, timeout);
    task.execute(config, mHandler, mExecutors);
}

From source file:com.streaming.sweetplayer.PlayerActivity.java

/**
 * Update the progressbar and time during playback.
 *
 * @param intent Intent// w  w  w. j a va2  s .c o  m
 */
private void updateControlsTime(Intent intent) {
    if (PlayerService.isCompleted) {
        mLoadingBar.setVisibility(View.GONE);
        String artistName = intent.getStringExtra("artistName");
        String songName = intent.getStringExtra("songName");
        String artistImageName = intent.getStringExtra("artistImageName");
        loadImage(artistImageName);
        mArtistNameTextView.setText(artistName);
        mSongNameTextView.setText(songName);

        if (mDataBase != null) {
            if (!mDataBase.isOnPlayList(sSongId)) {
                if (mAddMenuItem != null) {
                    mAddMenuItem.setVisible(true);
                }
            }
        }
    }

    int currentDuration = intent.getIntExtra("currentDuration", 0);
    int totalDuration = intent.getIntExtra("totalDuration", 0);
    mCurrentDurationTextView.setText(Utils.getTotalDuration(Utils.toSeconds(currentDuration)));
    mTotalDurationTextView.setText(Utils.getTotalDuration(totalDuration));
    mProgressBar.setMax(totalDuration);
    mProgressBar.setProgress(Utils.toSeconds(currentDuration));
}

From source file:alaindc.crowdroid.View.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    listGeofenceCircle = new HashMap<>();
    listCircles = new HashMap<>();

    SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
            .findFragmentById(R.id.map);
    mapFragment.getMapAsync(this);

    textView = (TextView) findViewById(R.id.textView);
    textView.setMovementMethod(new ScrollingMovementMethod());

    sensorsCheckbox = (CheckBox) findViewById(R.id.sensorscheck);
    requestsCheckbox = (CheckBox) findViewById(R.id.requestscheck);

    this.settingsButton = (Button) findViewById(R.id.settbutton);
    settingsButton.setOnClickListener(new View.OnClickListener() {
        @Override// w w w  .  j a  v  a 2s  . c  o  m
        public void onClick(View v) {
            Intent i = new Intent(getApplicationContext(), StakeholdersActivity.class);
            startActivity(i);
        }
    });

    this.requestButton = (Button) findViewById(R.id.button);
    requestButton.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            // TODO: Disable
            //requestButton.setEnabled(false);

            // Start sending messages to server
            Intent serviceIntent[] = new Intent[Constants.MONITORED_SENSORS.length];
            for (int i = 0; i < Constants.MONITORED_SENSORS.length; i++) {
                serviceIntent[i] = new Intent(getApplicationContext(), SendIntentService.class);
                serviceIntent[i].setAction(Constants.ACTION_SENDDATA + Constants.MONITORED_SENSORS[i]);
                serviceIntent[i].putExtra(Constants.EXTRA_TYPE_OF_SENSOR_TO_SEND,
                        Constants.MONITORED_SENSORS[i]); // TODO Here set to send all kind of sensor for start
                getApplicationContext().startService(serviceIntent[i]);

            }
        }
    });

    this.sensorButton = (Button) findViewById(R.id.buttonLoc);
    sensorButton.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            sensorButton.setEnabled(false);

            // Clear preferences
            getSharedPreferences(Constants.PREF_FILE, Context.MODE_PRIVATE).edit().clear().commit();

            // Start service for PhoneListener
            Intent phoneListIntent = new Intent(getApplicationContext(), NeverSleepService.class);
            getApplicationContext().startService(phoneListIntent);

            // Start intent service for update position
            Intent posintent = new Intent(getApplicationContext(), PositionIntentService.class);
            getApplicationContext().startService(posintent);

            // Start intent service for update sensors
            Intent sensorintent = new Intent(getApplicationContext(), SensorsIntentService.class);
            sensorintent.setAction(Constants.INTENT_START_SENSORS);
            getApplicationContext().startService(sensorintent);

            // Start intent service for update amplitude sensing
            Intent amplintent = new Intent(getApplicationContext(), SensorsIntentService.class);
            amplintent.setAction(Constants.INTENT_START_AUDIOAMPLITUDE_SENSE);
            getApplicationContext().startService(amplintent);
        }
    });

    BroadcastReceiver receiver = new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
            if (intent.getAction().equals(Constants.INTENT_RECEIVED_DATA)) {
                String response = intent.getStringExtra(Constants.INTENT_RECEIVED_DATA_EXTRA_DATA);
                if (response != null && requestsCheckbox.isChecked())
                    textView.append(response + "\n");
            } else if (intent.getAction().equals(Constants.INTENT_UPDATE_POS)) {
                setLocationAndMap();
            } else if (intent.getAction().equals(Constants.INTENT_UPDATE_SENSORS)) {
                String response = intent.getStringExtra(Constants.INTENT_RECEIVED_DATA_EXTRA_DATA);
                if (response != null && sensorsCheckbox.isChecked())
                    textView.append(response + "\n");
            } else if (intent.getAction().equals(Constants.INTENT_UPDATE_GEOFENCEVIEW)) { // Geofencing
                addGeofenceView(intent.getIntExtra(Constants.INTENT_GEOFENCEEXTRA_SENSOR, 0),
                        intent.getDoubleExtra(Constants.INTENT_GEOFENCEEXTRA_LATITUDE, 0),
                        intent.getDoubleExtra(Constants.INTENT_GEOFENCEEXTRA_LONGITUDE, 0),
                        intent.getFloatExtra(Constants.INTENT_GEOFENCEEXTRA_RADIUS, 100));
            } else {
                Log.d("", "");
            }
        }
    };

    IntentFilter rcvDataIntFilter = new IntentFilter(Constants.INTENT_RECEIVED_DATA);
    IntentFilter updatePosIntFilter = new IntentFilter(Constants.INTENT_UPDATE_POS);
    IntentFilter updateSenseIntFilter = new IntentFilter(Constants.INTENT_UPDATE_SENSORS);
    IntentFilter updateGeofenceViewIntFilter = new IntentFilter(Constants.INTENT_UPDATE_GEOFENCEVIEW);
    LocalBroadcastManager.getInstance(this).registerReceiver(receiver, rcvDataIntFilter);
    LocalBroadcastManager.getInstance(this).registerReceiver(receiver, updatePosIntFilter);
    LocalBroadcastManager.getInstance(this).registerReceiver(receiver, updateSenseIntFilter);
    LocalBroadcastManager.getInstance(this).registerReceiver(receiver, updateGeofenceViewIntFilter);

}

From source file:com.chatwing.whitelabel.managers.ChatboxModeManager.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Intent intent = mActivityDelegate.getActivity().getIntent();
    String action = intent.getAction();

    int recentChatboxID = mCommunicationActivityManager.getInt(R.string.current_chatbox_id, 0);
    if (mChatBoxIdValidator.isValid(recentChatboxID)) {
        mRequestedChatboxId = recentChatboxID;
    }//from w  ww .j  a  v a 2 s.  co  m

    if (CommunicationActivity.ACTION_OPEN_CHATBOX.equals(action)) {
        mRequestedChatboxId = intent.getIntExtra(CommunicationActivity.CHATBOX_ID, 0);
    }
}

From source file:com.dm.material.dashboard.candybar.activities.CandyBarMainActivity.java

@Override
public void onWallpapersChecked(@Nullable Intent intent) {
    if (intent != null) {
        String packageName = intent.getStringExtra("packageName");
        LogUtil.d("Broadcast received from service with packageName: " + packageName);

        if (packageName == null)
            return;

        if (!packageName.equals(getPackageName())) {
            LogUtil.d("Received broadcast from different packageName, expected: " + getPackageName());
            return;
        }// w w w .  j av  a 2  s.  co m

        int size = intent.getIntExtra("size", 0);
        Database database = new Database(this);
        int offlineSize = database.getWallpapersCount();
        Preferences.getPreferences(this).setAvailableWallpapersCount(size);

        if (size > offlineSize) {
            if (mFragmentTag.equals(TAG_HOME)) {
                HomeFragment fragment = (HomeFragment) mFragManager.findFragmentByTag(TAG_HOME);
                if (fragment != null)
                    fragment.resetWallpapersCount();
            }

            int accent = ColorHelper.getAttributeColor(this, R.attr.colorAccent);
            LinearLayout container = (LinearLayout) mNavigationView.getMenu().getItem(4).getActionView();
            if (container != null) {
                TextView counter = (TextView) container.findViewById(R.id.counter);
                if (counter == null)
                    return;

                ViewCompat.setBackground(counter,
                        DrawableHelper.getTintedDrawable(this, R.drawable.ic_toolbar_circle, accent));
                counter.setTextColor(ColorHelper.getTitleTextColor(accent));
                int newItem = (size - offlineSize);
                counter.setText(String.valueOf(newItem > 99 ? "99+" : newItem));
                container.setVisibility(View.VISIBLE);
                return;
            }
        }
    }

    LinearLayout container = (LinearLayout) mNavigationView.getMenu().getItem(4).getActionView();
    if (container != null)
        container.setVisibility(View.GONE);
}

From source file:com.digitalarx.android.files.services.FileUploader.java

/**
 * Entry point to add one or several files to the queue of uploads.
 * /*from w  w  w. j  ava 2 s.  com*/
 * New uploads are added calling to startService(), resulting in a call to
 * this method. This ensures the service will keep on working although the
 * caller activity goes away.
 */
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
    if (!intent.hasExtra(KEY_ACCOUNT) || !intent.hasExtra(KEY_UPLOAD_TYPE)
            || !(intent.hasExtra(KEY_LOCAL_FILE) || intent.hasExtra(KEY_FILE))) {
        Log_OC.e(TAG, "Not enough information provided in intent");
        return Service.START_NOT_STICKY;
    }
    int uploadType = intent.getIntExtra(KEY_UPLOAD_TYPE, -1);
    if (uploadType == -1) {
        Log_OC.e(TAG, "Incorrect upload type provided");
        return Service.START_NOT_STICKY;
    }
    Account account = intent.getParcelableExtra(KEY_ACCOUNT);

    String[] localPaths = null, remotePaths = null, mimeTypes = null;
    OCFile[] files = null;
    if (uploadType == UPLOAD_SINGLE_FILE) {

        if (intent.hasExtra(KEY_FILE)) {
            files = new OCFile[] { intent.getParcelableExtra(KEY_FILE) };

        } else {
            localPaths = new String[] { intent.getStringExtra(KEY_LOCAL_FILE) };
            remotePaths = new String[] { intent.getStringExtra(KEY_REMOTE_FILE) };
            mimeTypes = new String[] { intent.getStringExtra(KEY_MIME_TYPE) };
        }

    } else { // mUploadType == UPLOAD_MULTIPLE_FILES

        if (intent.hasExtra(KEY_FILE)) {
            files = (OCFile[]) intent.getParcelableArrayExtra(KEY_FILE); // TODO
                                                                         // will
                                                                         // this
                                                                         // casting
                                                                         // work
                                                                         // fine?

        } else {
            localPaths = intent.getStringArrayExtra(KEY_LOCAL_FILE);
            remotePaths = intent.getStringArrayExtra(KEY_REMOTE_FILE);
            mimeTypes = intent.getStringArrayExtra(KEY_MIME_TYPE);
        }
    }

    FileDataStorageManager storageManager = new FileDataStorageManager(account, getContentResolver());

    boolean forceOverwrite = intent.getBooleanExtra(KEY_FORCE_OVERWRITE, false);
    boolean isInstant = intent.getBooleanExtra(KEY_INSTANT_UPLOAD, false);
    int localAction = intent.getIntExtra(KEY_LOCAL_BEHAVIOUR, LOCAL_BEHAVIOUR_COPY);

    if (intent.hasExtra(KEY_FILE) && files == null) {
        Log_OC.e(TAG, "Incorrect array for OCFiles provided in upload intent");
        return Service.START_NOT_STICKY;

    } else if (!intent.hasExtra(KEY_FILE)) {
        if (localPaths == null) {
            Log_OC.e(TAG, "Incorrect array for local paths provided in upload intent");
            return Service.START_NOT_STICKY;
        }
        if (remotePaths == null) {
            Log_OC.e(TAG, "Incorrect array for remote paths provided in upload intent");
            return Service.START_NOT_STICKY;
        }
        if (localPaths.length != remotePaths.length) {
            Log_OC.e(TAG, "Different number of remote paths and local paths!");
            return Service.START_NOT_STICKY;
        }

        files = new OCFile[localPaths.length];
        for (int i = 0; i < localPaths.length; i++) {
            files[i] = obtainNewOCFileToUpload(remotePaths[i], localPaths[i],
                    ((mimeTypes != null) ? mimeTypes[i] : (String) null), storageManager);
            if (files[i] == null) {
                // TODO @andomaex add failure Notification
                return Service.START_NOT_STICKY;
            }
        }
    }

    AccountManager aMgr = AccountManager.get(this);
    String version = aMgr.getUserData(account, Constants.KEY_OC_VERSION);
    OwnCloudVersion ocv = new OwnCloudVersion(version);

    boolean chunked = FileUploader.chunkedUploadIsSupported(ocv);
    AbstractList<String> requestedUploads = new Vector<String>();
    String uploadKey = null;
    UploadFileOperation newUpload = null;
    try {
        for (int i = 0; i < files.length; i++) {
            uploadKey = buildRemoteName(account, files[i].getRemotePath());
            newUpload = new UploadFileOperation(account, files[i], chunked, isInstant, forceOverwrite,
                    localAction, getApplicationContext());
            if (isInstant) {
                newUpload.setRemoteFolderToBeCreated();
            }
            mPendingUploads.putIfAbsent(uploadKey, newUpload); // Grants that the file only upload once time

            newUpload.addDatatransferProgressListener(this);
            newUpload.addDatatransferProgressListener((FileUploaderBinder) mBinder);
            requestedUploads.add(uploadKey);
        }

    } catch (IllegalArgumentException e) {
        Log_OC.e(TAG, "Not enough information provided in intent: " + e.getMessage());
        return START_NOT_STICKY;

    } catch (IllegalStateException e) {
        Log_OC.e(TAG, "Bad information provided in intent: " + e.getMessage());
        return START_NOT_STICKY;

    } catch (Exception e) {
        Log_OC.e(TAG, "Unexpected exception while processing upload intent", e);
        return START_NOT_STICKY;

    }

    if (requestedUploads.size() > 0) {
        Message msg = mServiceHandler.obtainMessage();
        msg.arg1 = startId;
        msg.obj = requestedUploads;
        mServiceHandler.sendMessage(msg);
    }
    Log_OC.i(TAG, "mPendingUploads size:" + mPendingUploads.size());
    return Service.START_NOT_STICKY;
}