Example usage for android.content Intent hasExtra

List of usage examples for android.content Intent hasExtra

Introduction

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

Prototype

public boolean hasExtra(String name) 

Source Link

Document

Returns true if an extra value is associated with the given name.

Usage

From source file:com.dvn.vindecoder.ui.user.GetAllVehicalDetails.java

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    Log.e("Activity sss1", "sds");
    if (requestCode == GALLERY_REQUEST) {
        if (resultCode == RESULT_OK) {
            if (data != null) {
                uri = data.getData();//from   w w w. j  a  v a  2  s .c  o  m
                image_path = uri.getPath();
                //addNewVehicalFragment.setImagePath(image_path);
                BitmapFactory.Options options = new BitmapFactory.Options();
                options.inJustDecodeBounds = true;
                try {
                    // BitmapFactory.decodeStream(getContentResolver().openInputStream(uri), null, options);
                    options.inSampleSize = calculateInSampleSize(options, 100, 100);
                    options.inJustDecodeBounds = false;
                    Bitmap image = BitmapFactory.decodeStream(getContentResolver().openInputStream(uri), null,
                            options);

                    //   car_image.setImageBitmap(image);
                    //car_image1.setImageBitmap(image);

                    /* Bitmap bitmap = ((BitmapDrawable) car_image.getDrawable()).getBitmap();
                     ByteArrayOutputStream bytes = new ByteArrayOutputStream();
                     bitmap.compress(Bitmap.CompressFormat.JPEG, 90, bytes);
                     File destination = new File(getCacheDir(), "car.jpg");
                     FileOutputStream fo;
                     try {
                    fo = new FileOutputStream(destination);
                    fo.write(bytes.toByteArray());
                    fo.close();
                     } catch (IOException e) {
                    e.printStackTrace();
                     }
                     image_path = destination.getAbsolutePath();*/
                    // car_image.setImageBitmap(bitmap);
                    //  addNewVehicalFragment.setImagePath(image_path);

                } catch (Exception e) {
                    e.printStackTrace();
                }
            } else {
                Toast.makeText(getApplicationContext(), "Cancelled", Toast.LENGTH_SHORT).show();
            }
        } else if (resultCode == RESULT_CANCELED) {
            Toast.makeText(getApplicationContext(), "Cancelled", Toast.LENGTH_SHORT).show();
        }
    } else if (requestCode == CAMERA_REQUEST) {
        if (resultCode == RESULT_OK) {
            if (data.hasExtra("data")) {
                Bitmap bitmap = (Bitmap) data.getExtras().get("data");
                /* ByteArrayOutputStream bytes = new ByteArrayOutputStream();
                 bitmap.compress(Bitmap.CompressFormat.JPEG, 90, bytes);
                 File destination = new File(getCacheDir(), "car.jpg");
                 FileOutputStream fo;
                 try {
                fo = new FileOutputStream(destination);
                fo.write(bytes.toByteArray());
                fo.close();
                 } catch (IOException e) {
                e.printStackTrace();
                 }
                 image_path = destination.getAbsolutePath();*/
                //  car_image.setImageBitmap(bitmap);
                //  car_image1.setImageBitmap(bitmap);
                // addNewVehicalFragment.setImagePath(image_path);
            } else if (data.getExtras() == null) {

                Toast.makeText(getApplicationContext(), "No extras to retrieve!", Toast.LENGTH_SHORT).show();

                BitmapDrawable thumbnail = new BitmapDrawable(getResources(), data.getData().getPath());
                //img_view_drivingLicense.setImageDrawable(thumbnail);
                //    car_image.setImageDrawable(thumbnail);
                //  car_image1.setImageDrawable(thumbnail);

            }

        } else if (resultCode == RESULT_CANCELED) {
            Toast.makeText(getApplicationContext(), "Cancelled", Toast.LENGTH_SHORT).show();
        }
    }
}

From source file:com.github.dfa.diaspora_android.activity.MainActivity.java

/**
 * Handle intents and execute intent specific actions
 *
 * @param intent intent to get handled//ww w  . j  a  v a2  s . co  m
 */
private void handleIntent(Intent intent) {
    AppLog.i(this, "handleIntent()");
    if (intent == null) {
        AppLog.v(this, "Intent was null");
        return;
    }

    String action = intent.getAction();
    String type = intent.getType();
    String loadUrl = null;
    AppLog.v(this, "Action: " + action + " Type: " + type);
    if (Intent.ACTION_MAIN.equals(action)) {
        loadUrl = urls.getStreamUrl();
    } else if (ACTION_OPEN_URL.equals(action)) {
        loadUrl = intent.getStringExtra(URL_MESSAGE);
    } else if (Intent.ACTION_VIEW.equals(action) && intent.getDataString() != null) {
        Uri data = intent.getData();
        if (data != null && data.toString().startsWith(CONTENT_HASHTAG)) {
            handleHashtag(intent);
            return;
        } else {
            loadUrl = intent.getDataString();
            AppLog.v(this, "Intent has a delicious URL for us: " + loadUrl);
        }
    } else if (ACTION_CHANGE_ACCOUNT.equals(action)) {
        AppLog.v(this, "Reset pod data and  show PodSelectionFragment");
        appSettings.setPod(null);
        runOnUiThread(new Runnable() {
            public void run() {
                navheaderTitle.setText(R.string.app_name);
                navheaderDescription.setText(R.string.app_subtitle);
                navheaderImage.setImageResource(R.drawable.ic_launcher);
                app.resetPodData(
                        ((DiasporaStreamFragment) getFragment(DiasporaStreamFragment.TAG)).getWebView());
            }
        });
        showFragment(getFragment(PodSelectionFragment.TAG));
    } else if (ACTION_CLEAR_CACHE.equals(action)) {
        AppLog.v(this, "Clear WebView cache");
        runOnUiThread(new Runnable() {
            public void run() {
                ContextMenuWebView wv = ((DiasporaStreamFragment) getFragment(DiasporaStreamFragment.TAG))
                        .getWebView();
                if (wv != null) {
                    wv.clearCache(true);
                }
            }
        });

    } else if (Intent.ACTION_SEND.equals(action) && type != null) {
        switch (type) {
        case "text/plain":
            if (intent.hasExtra(Intent.EXTRA_SUBJECT)) {
                handleSendSubject(intent);
            } else {
                handleSendText(intent);
            }
            break;
        case "image/*":
            handleSendImage(intent); //TODO: Add intent filter to Manifest and implement method
            break;
        }
    } else if (Intent.ACTION_SEND_MULTIPLE.equals(action) && type != null) {
        /* TODO: Implement and add filter to manifest */
        return;
    }
    //Catch split screen recreation
    if (action != null && action.equals(Intent.ACTION_MAIN) && getTopFragment() != null) {
        return;
    }

    if (loadUrl != null) {
        navDrawer.closeDrawers();
        openDiasporaUrl(loadUrl);
    }
}

From source file:com.dycody.android.idealnote.ListFragment.java

/**
 * Notes list adapter initialization and association to view
 */// w ww  .j ava2s  .co  m
void initNotesList(Intent intent) {
    Log.d(Constants.TAG, "initNotesList intent: " + intent.getAction());

    progress_wheel.setAlpha(1);
    list.setAlpha(0);

    // Search for a tag
    // A workaround to simplify it's to simulate normal search
    if (Intent.ACTION_VIEW.equals(intent.getAction()) && intent.getCategories() != null
            && intent.getCategories().contains(Intent.CATEGORY_BROWSABLE)) {
        searchTags = intent.getDataString().replace(UrlCompleter.HASHTAG_SCHEME, "");
        goBackOnToggleSearchLabel = true;
    }

    // Searching
    searchQuery = searchQueryInstant;
    searchQueryInstant = null;
    if (searchTags != null || searchQuery != null || Intent.ACTION_SEARCH.equals(intent.getAction())) {

        // Using tags
        if (searchTags != null && intent.getStringExtra(SearchManager.QUERY) == null) {
            searchQuery = searchTags;
            NoteLoaderTask.getInstance().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, "getNotesByTag",
                    searchQuery);
        } else {
            // Get the intent, verify the action and get the query
            if (intent.getStringExtra(SearchManager.QUERY) != null) {
                searchQuery = intent.getStringExtra(SearchManager.QUERY);
                searchTags = null;
            }
            NoteLoaderTask.getInstance().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, "getNotesByPattern",
                    searchQuery);
        }

        toggleSearchLabel(true);

    } else {
        // Check if is launched from a widget with categories
        if ((Constants.ACTION_WIDGET_SHOW_LIST.equals(intent.getAction())
                && intent.hasExtra(Constants.INTENT_WIDGET))
                || !TextUtils.isEmpty(mainActivity.navigationTmp)) {
            String widgetId = intent.hasExtra(Constants.INTENT_WIDGET)
                    ? intent.getExtras().get(Constants.INTENT_WIDGET).toString()
                    : null;
            if (widgetId != null) {
                String sqlCondition = prefs.getString(Constants.PREF_WIDGET_PREFIX + widgetId, "");
                String categoryId = TextHelper.checkIntentCategory(sqlCondition);
                mainActivity.navigationTmp = !TextUtils.isEmpty(categoryId) ? categoryId : null;
            }
            intent.removeExtra(Constants.INTENT_WIDGET);
            if (mainActivity.navigationTmp != null) {
                Long categoryId = Long.parseLong(mainActivity.navigationTmp);
                NoteLoaderTask.getInstance().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR,
                        "getNotesByCategory", categoryId);
            } else {
                NoteLoaderTask.getInstance().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, "getAllNotes",
                        true);
            }

        } else {
            NoteLoaderTask.getInstance().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, "getAllNotes", true);
        }
    }
}

From source file:com.kaichaohulian.baocms.ecdemo.ui.chatting.ChattingFragment.java

@Override
protected void handleReceiver(Context context, Intent intent) {
    super.handleReceiver(context, intent);
    if (IMessageSqlManager.ACTION_GROUP_DEL.equals(intent.getAction()) && intent.hasExtra("group_id")) {
        String id = intent.getStringExtra("group_id");
        if (id != null && id.equals(mRecipients)) {
            setIsFinish(true);/*from   www.  ja v a 2  s . co  m*/
            finish();
        }
    } else if (IMChattingHelper.INTENT_ACTION_CHAT_USER_STATE.equals(intent.getAction())) {

        String state = intent.getStringExtra(IMChattingHelper.USER_STATE);
        if (!TextUtils.isEmpty(state) && Integer.parseInt(state) == ImUserState.WRITE.ordinal()) {
            setActionBarTitle("...");
        } else if (!TextUtils.isEmpty(state) && Integer.parseInt(state) == ImUserState.RECORDE.ordinal()) {
            setActionBarTitle("...");
        } else {
            setActionBarTitle(mUsername);
        }

    } else if (IMChattingHelper.INTENT_ACTION_CHAT_EDITTEXT_FOUCU.equals(intent.getAction())) {

        boolean hasFoucs = intent.getBooleanExtra("hasFoucs", false);
        if (hasFoucs) {
            handleSendUserStateMessage("1");
        } else {
            handleSendUserStateMessage("0");
        }

    }
}

From source file:it.feio.android.omninotes.DetailFragment.java

private void handleIntents() {
    Intent i = mainActivity.getIntent();

    if (IntentChecker.checkAction(i, Constants.ACTION_MERGE)) {
        noteOriginal = new Note();
        note = new Note(noteOriginal);
        noteTmp = getArguments().getParcelable(Constants.INTENT_NOTE);
        if (i.getStringArrayListExtra("merged_notes") != null) {
            mergedNotesIds = i.getStringArrayListExtra("merged_notes");
        }//from w w  w.j a  v a 2s  . c  o m
    }

    // Action called from home shortcut
    if (IntentChecker.checkAction(i, Constants.ACTION_SHORTCUT, Constants.ACTION_NOTIFICATION_CLICK)) {
        afterSavedReturnsToList = false;
        noteOriginal = DbHelper.getInstance().getNote(i.getLongExtra(Constants.INTENT_KEY, 0));
        // Checks if the note pointed from the shortcut has been deleted
        try {
            note = new Note(noteOriginal);
            noteTmp = new Note(noteOriginal);
        } catch (NullPointerException e) {
            mainActivity.showToast(getText(R.string.shortcut_note_deleted), Toast.LENGTH_LONG);
            mainActivity.finish();
        }
    }

    // Check if is launched from a widget
    if (IntentChecker.checkAction(i, Constants.ACTION_WIDGET, Constants.ACTION_TAKE_PHOTO)) {

        afterSavedReturnsToList = false;
        showKeyboard = true;

        //  with tags to set tag
        if (i.hasExtra(Constants.INTENT_WIDGET)) {
            String widgetId = i.getExtras().get(Constants.INTENT_WIDGET).toString();
            if (widgetId != null) {
                String sqlCondition = prefs.getString(Constants.PREF_WIDGET_PREFIX + widgetId, "");
                String categoryId = TextHelper.checkIntentCategory(sqlCondition);
                if (categoryId != null) {
                    Category category;
                    try {
                        category = DbHelper.getInstance().getCategory(Long.parseLong(categoryId));
                        noteTmp = new Note();
                        noteTmp.setCategory(category);
                    } catch (NumberFormatException e) {
                        Log.e(Constants.TAG, "Category with not-numeric value!", e);
                    }
                }
            }
        }

        // Sub-action is to take a photo
        if (IntentChecker.checkAction(i, Constants.ACTION_TAKE_PHOTO)) {
            takePhoto();
        }
    }

    /**
     * Handles third party apps requests of sharing
     */
    if (IntentChecker.checkAction(i, Intent.ACTION_SEND, Intent.ACTION_SEND_MULTIPLE,
            Constants.INTENT_GOOGLE_NOW) && i.getType() != null) {

        afterSavedReturnsToList = false;

        if (noteTmp == null)
            noteTmp = new Note();

        // Text title
        String title = i.getStringExtra(Intent.EXTRA_SUBJECT);
        if (title != null) {
            noteTmp.setTitle(title);
        }

        // Text content
        String content = i.getStringExtra(Intent.EXTRA_TEXT);
        if (content != null) {
            noteTmp.setContent(content);
        }

        // Single attachment data
        Uri uri = i.getParcelableExtra(Intent.EXTRA_STREAM);
        // Due to the fact that Google Now passes intent as text but with
        // audio recording attached the case must be handled in specific way
        if (uri != null && !Constants.INTENT_GOOGLE_NOW.equals(i.getAction())) {
            String name = FileHelper.getNameFromUri(mainActivity, uri);
            AttachmentTask task = new AttachmentTask(this, uri, name, this);
            task.execute();
        }

        // Multiple attachment data
        ArrayList<Uri> uris = i.getParcelableArrayListExtra(Intent.EXTRA_STREAM);
        if (uris != null) {
            for (Uri uriSingle : uris) {
                String name = FileHelper.getNameFromUri(mainActivity, uriSingle);
                AttachmentTask task = new AttachmentTask(this, uriSingle, name, this);
                task.execute();
            }
        }

        //         i.setAction(null);
    }

    if (IntentChecker.checkAction(i, Intent.ACTION_MAIN, Constants.ACTION_WIDGET_SHOW_LIST)) {
        showKeyboard = true;
    }

}

From source file:com.moonpi.swiftnotes.MainActivity.java

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (resultCode == RESULT_OK) {
        Bundle mBundle = data.getExtras();

        if (mBundle != null) {
            // If new note was saved
            if (requestCode == NEW_NOTE_REQUEST) {
                try {
                    // Add new note to array
                    JSONObject newNote = new JSONObject();
                    newNote.put("title", mBundle.getString("title"));
                    newNote.put("body", mBundle.getString("body"));
                    newNote.put("colour", mBundle.getString("colour"));
                    newNote.put("favoured", false);
                    newNote.put("fontSize", mBundle.getInt("fontSize"));

                    notes.put(newNote);//  www  .  ja  v a2s  .com
                    adapter.notifyDataSetChanged();

                    writeToJSON();

                    // If no notes, show 'Press + to add new note' text, invisible otherwise
                    if (notes.length() == 0)
                        noNotes.setVisibility(View.VISIBLE);
                    else
                        noNotes.setVisibility(View.INVISIBLE);

                    Toast toast = Toast.makeText(getApplicationContext(),
                            getResources().getString(R.string.toast_new_note), Toast.LENGTH_SHORT);
                    toast.show();

                } catch (JSONException e) {
                    e.printStackTrace();
                }
            }

            // If existing note was saved
            else {
                try {
                    // Update array with new data
                    JSONObject newNote = notes.getJSONObject(requestCode);
                    newNote.put("title", mBundle.getString("title"));
                    newNote.put("body", mBundle.getString("body"));
                    newNote.put("colour", mBundle.getString("colour"));
                    newNote.put("fontSize", mBundle.getInt("fontSize"));

                    // Update note at position
                    notes.put(requestCode, newNote);
                    adapter.notifyDataSetChanged();

                    writeToJSON();

                    Toast toast = Toast.makeText(getApplicationContext(),
                            getResources().getString(R.string.toast_note_saved), Toast.LENGTH_SHORT);
                    toast.show();

                } catch (JSONException e) {
                    e.printStackTrace();
                }
            }
        }
    }

    else if (resultCode == RESULT_CANCELED) {
        Bundle mBundle = null;

        if (data != null && data.hasExtra("request"))
            mBundle = data.getExtras();

        if (requestCode == NEW_NOTE_REQUEST) {
            if (mBundle != null) {
                // If new note discarded, show toast
                if (mBundle.getString("request").equals("discard")) {
                    Toast toast = Toast.makeText(getApplicationContext(),
                            getResources().getString(R.string.toast_empty_note_discarded), Toast.LENGTH_SHORT);
                    toast.show();
                }
            }
        }

        else {
            if (mBundle != null) {
                // If delete pressed in EditActivity, call deleteNote method with
                // requestCode as position
                if (mBundle.getString("request").equals("delete"))
                    deleteNote(this, requestCode);
            }
        }
    }

    super.onActivityResult(requestCode, resultCode, data);
}

From source file:com.andrew.apollo.MusicPlaybackService.java

/**
 * {@inheritDoc}/*from  w  w w. j av a 2s  .  co m*/
 */
@Override
public int onStartCommand(final Intent intent, final int flags, final int startId) {
    if (D)
        LOG.info("Got new intent " + intent + ", startId = " + startId);
    mServiceStartId = startId;

    if (intent != null) {
        final String action = intent.getAction();

        if (intent.hasExtra(NOW_IN_FOREGROUND)) {
            musicPlaybackActivityInForeground = intent.getBooleanExtra(NOW_IN_FOREGROUND, false);
            updateNotification();
        }

        if (SHUTDOWN_ACTION.equals(action)) {
            cancelShutdown();
            exiting = intent.hasExtra("force");
            releaseServiceUiAndStop(exiting);
            return START_NOT_STICKY;
        }

        handleCommandIntent(intent);
    }

    // Make sure the service will shut down on its own if it was
    // just started but not bound to and nothing is playing
    scheduleDelayedShutdown();

    if (intent != null && intent.getBooleanExtra(FROM_MEDIA_BUTTON, false)) {
        MediaButtonIntentReceiver.completeWakefulIntent(intent);
    }

    return START_STICKY;
}

From source file:com.github.michalbednarski.intentslab.editor.IntentEditorActivity.java

@Override
protected void onActivityResult(int requestCode, final int resultCode, final Intent resultIntent) {
    if (requestCode == REQUEST_CODE_TEST_STARTACTIVITYFORRESULT) {
        // Result of tested startActivityForResult
        if (resultIntent == null) {
            Toast.makeText(this, getString(R.string.startactivityforresult_no_result, resultCode),
                    Toast.LENGTH_SHORT).show();
        } else {//  w ww.  j  a v a2s  .  c om
            AlertDialog.Builder alertBuilder = new AlertDialog.Builder(this)
                    .setMessage(getString(R.string.startactivityforresult_got_result));

            if (isInterceptedIntent() && (getCallingPackage() != null)) {
                alertBuilder.setPositiveButton(getString(R.string.edit_intercepted_result),
                        new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog, int which) {
                                startActivityForResult(
                                        new Intent(IntentEditorActivity.this, IntentEditorActivity.class)
                                                .putExtra(EXTRA_INTENT, resultIntent)
                                                .putExtra(EXTRA_COMPONENT_TYPE, IntentEditorConstants.RESULT)
                                                .putExtra(EXTRA_METHOD_ID, resultCode)
                                                .putExtra(EXTRA_FORWARD_ABLE_RESULT, true),
                                        REQUEST_CODE_RESULT_INTENT_EDITOR);
                            }
                        }).setNeutralButton(getString(R.string.forward_intercepted_result),
                                new DialogInterface.OnClickListener() {
                                    @Override
                                    public void onClick(DialogInterface dialog, int which) {
                                        setResult(resultCode, resultIntent);
                                        finish();
                                    }
                                });
            } else {
                alertBuilder.setPositiveButton(getString(R.string.startactivityforresult_view_result),
                        new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog, int which) {
                                startActivity(new Intent(IntentEditorActivity.this, IntentEditorActivity.class)
                                        .putExtra(EXTRA_INTENT, resultIntent)
                                        .putExtra(EXTRA_COMPONENT_TYPE, IntentEditorConstants.RESULT));
                            }
                        });
            }
            alertBuilder.setNegativeButton(getString(R.string.cancel), null).show();
        }

    } else if (requestCode == REQUEST_CODE_RESULT_INTENT_EDITOR) {
        // Result intent editor requesting forward result
        if (resultIntent != null && resultIntent.hasExtra(EXTRA_FORWARD_RESULT_INTENT)) {
            setResult(resultIntent.getIntExtra(EXTRA_FORWARD_RESULT_CODE, 0),
                    (Intent) resultIntent.getParcelableExtra(EXTRA_FORWARD_RESULT_INTENT));
            finish();
        }

    } else if (requestCode == REQUEST_CODE_REQUEST_INTENT_TRACKER_PERMISSION) {
        if (resultCode == RESULT_OK) {
            createIntentTracker();
        }
    } else {
        super.onActivityResult(requestCode, resultCode, resultIntent);
    }
}

From source file:com.dycody.android.idealnote.DetailFragment.java

private void handleIntents() {
    Intent i = mainActivity.getIntent();

    if (IntentChecker.checkAction(i, Constants.ACTION_MERGE)) {
        noteOriginal = new Note();
        note = new Note(noteOriginal);
        noteTmp = getArguments().getParcelable(Constants.INTENT_NOTE);
        if (i.getStringArrayListExtra("merged_notes") != null) {
            mergedNotesIds = i.getStringArrayListExtra("merged_notes");
        }/*w  ww . ja  v a2 s  .c  om*/
    }

    // Action called from home shortcut
    if (IntentChecker.checkAction(i, Constants.ACTION_SHORTCUT, Constants.ACTION_NOTIFICATION_CLICK)) {
        afterSavedReturnsToList = false;
        noteOriginal = DbHelper.getInstance().getNote(i.getLongExtra(Constants.INTENT_KEY, 0));
        // Checks if the note pointed from the shortcut has been deleted
        try {
            note = new Note(noteOriginal);
            noteTmp = new Note(noteOriginal);
        } catch (NullPointerException e) {
            mainActivity.showToast(getText(R.string.shortcut_note_deleted), Toast.LENGTH_LONG);
            mainActivity.finish();
        }
    }

    // Check if is launched from a widget
    if (IntentChecker.checkAction(i, Constants.ACTION_WIDGET, Constants.ACTION_TAKE_PHOTO)) {

        afterSavedReturnsToList = false;
        showKeyboard = true;

        //  with tags to set tag
        if (i.hasExtra(Constants.INTENT_WIDGET)) {
            String widgetId = i.getExtras().get(Constants.INTENT_WIDGET).toString();
            if (widgetId != null) {
                String sqlCondition = prefs.getString(Constants.PREF_WIDGET_PREFIX + widgetId, "");
                String categoryId = TextHelper.checkIntentCategory(sqlCondition);
                if (categoryId != null) {
                    Category category;
                    try {
                        category = DbHelper.getInstance().getCategory(Long.parseLong(categoryId));
                        noteTmp = new Note();
                        noteTmp.setCategory(category);
                    } catch (NumberFormatException e) {
                        Log.e(Constants.TAG, "Category with not-numeric value!", e);
                    }
                }
            }
        }

        // Sub-action is to take a photo
        if (IntentChecker.checkAction(i, Constants.ACTION_TAKE_PHOTO)) {
            takePhoto();
        }
    }

    /**
     * Handles third party apps requests of sharing
     */
    if (IntentChecker.checkAction(i, Intent.ACTION_SEND, Intent.ACTION_SEND_MULTIPLE,
            Constants.INTENT_GOOGLE_NOW) && i.getType() != null) {

        afterSavedReturnsToList = false;

        if (noteTmp == null)
            noteTmp = new Note();

        // Text title
        String title = i.getStringExtra(Intent.EXTRA_SUBJECT);
        if (title != null) {
            noteTmp.setTitle(title);
        }

        // Text content
        String content = i.getStringExtra(Intent.EXTRA_TEXT);
        if (content != null) {
            noteTmp.setContent(content);
        }

        // Single attachment data
        Uri uri = i.getParcelableExtra(Intent.EXTRA_STREAM);
        // Due to the fact that Google Now passes intent as text but with
        // audio recording attached the case must be handled in specific way
        if (uri != null && !Constants.INTENT_GOOGLE_NOW.equals(i.getAction())) {
            String name = FileHelper.getNameFromUri(mainActivity, uri);
            new AttachmentTask(this, uri, name, this).execute();
        }

        // Multiple attachment data
        ArrayList<Uri> uris = i.getParcelableArrayListExtra(Intent.EXTRA_STREAM);
        if (uris != null) {
            for (Uri uriSingle : uris) {
                String name = FileHelper.getNameFromUri(mainActivity, uriSingle);
                new AttachmentTask(this, uriSingle, name, this).execute();
            }
        }
    }

    if (IntentChecker.checkAction(i, Intent.ACTION_MAIN, Constants.ACTION_WIDGET_SHOW_LIST,
            Constants.ACTION_SHORTCUT_WIDGET, Constants.ACTION_WIDGET)) {
        showKeyboard = true;
    }

    i.setAction(null);
}