Example usage for android.content Intent ACTION_SEND

List of usage examples for android.content Intent ACTION_SEND

Introduction

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

Prototype

String ACTION_SEND

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

Click Source Link

Document

Activity Action: Deliver some data to someone else.

Usage

From source file:com.adkdevelopment.earthquakesurvival.ui.InfoFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    View rootView = inflater.inflate(R.layout.info_fragment, container, false);
    ImageView backdrop = ButterKnife.findById(getActivity(), R.id.backdrop);
    FloatingActionButton floatingActionButton = ButterKnife.findById(getActivity(), R.id.fab);

    mUnbinder = ButterKnife.bind(this, rootView);

    if (getActivity().getIntent() != null) {
        int section = getActivity().getIntent().getIntExtra(SurvivalFragment.SECTION, -1);
        List<String> titles = new ArrayList<>();
        List<String> text = new ArrayList<>();
        String title = "";

        int drawable = -1;

        switch (section) {
        case 1://from  w  ww  .j a  v a 2s  . co m
            titles.addAll(Arrays.asList(getResources().getStringArray(R.array.survival_before_title)));
            text.addAll(Arrays.asList(getResources().getStringArray(R.array.survival_before_text)));
            drawable = R.drawable.earth1;
            title = getString(R.string.survival_before);
            break;
        case 2:
            titles.addAll(Arrays.asList(getResources().getStringArray(R.array.survival_during_title)));
            text.addAll(Arrays.asList(getResources().getStringArray(R.array.survival_during_text)));
            drawable = R.drawable.earth2;
            title = getString(R.string.survival_during);
            break;
        case 3:
            titles.addAll(Arrays.asList(getResources().getStringArray(R.array.survival_after_title)));
            text.addAll(Arrays.asList(getResources().getStringArray(R.array.survival_after_text)));
            drawable = R.drawable.earth3;
            title = getString(R.string.survival_after);
            break;
        case 4:
            title = getString(R.string.survival_resources);
            titles.addAll(Arrays.asList(getResources().getStringArray(R.array.survival_resources_title)));
            text.addAll(Arrays.asList(getResources().getStringArray(R.array.survival_resources_text)));
            drawable = R.drawable.earth3;
            break;
        case 5:
            title = getString(R.string.survival_kit);
            titles.addAll(Arrays.asList(getResources().getStringArray(R.array.survival_kit_title)));
            text.addAll(Arrays.asList(getResources().getStringArray(R.array.survival_kit_text)));
            drawable = R.drawable.earth3;
            break;
        default:
            break;
        }

        RecyclerView.LayoutManager layoutManager = new LinearLayoutManager(getContext(), RecyclerView.VERTICAL,
                false);
        InfoAdapter mRecentAdapter = new InfoAdapter(titles, text);

        mRecyclerView.setHasFixedSize(true);
        mRecyclerView.setLayoutManager(layoutManager);
        mRecyclerView.setAdapter(mRecentAdapter);

        floatingActionButton.setOnClickListener(click -> {
            if (_rxBus.hasObservers()) {
                Intent intent = new Intent(Intent.ACTION_SEND);
                intent.setType("text/html");
                if (titles.size() > 0 && text.size() > 0) {
                    intent.putExtra(Intent.EXTRA_SUBJECT, titles.get(0));
                    intent.putExtra(Intent.EXTRA_TEXT, text.get(0));
                }
                _rxBus.send(Intent.createChooser(intent, getString(R.string.send_email)));
            }
        });

        ActionBar actionBar = ((AppCompatActivity) getActivity()).getSupportActionBar();
        if (actionBar != null) {
            actionBar.setTitle(title);
        }

        Picasso.with(getContext()).load(drawable).error(R.drawable.dropcoverholdon).into(backdrop);
    }
    return rootView;
}

From source file:com.arquitetaweb.observatorio.MainActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.main, menu);

    // Locate MenuItem with ShareActionProvider
    MenuItem item = menu.findItem(R.id.menu_item_share);
    // Fetch and store ShareActionProvider
    mShareActionProvider = (ShareActionProvider) item.getActionProvider();

    Intent mShareIntent = new Intent();
    mShareIntent.setAction(Intent.ACTION_SEND);
    mShareIntent.putExtra(Intent.EXTRA_TEXT,
            "Fique por dentro do oramento e despesas de Maring acesse o site e baixe o aplicativo.\nhttp://observatoriomga.herokuapp.com/#graph/pie/pai");

    mShareIntent.setType("*/*");

    if (mShareActionProvider != null) {
        mShareActionProvider.setShareIntent(mShareIntent);
    }// w ww  .ja v  a 2s .c  o  m

    return super.onCreateOptionsMenu(menu);
}

From source file:co.nerdart.ourss.activity.EditFeedActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    UiUtils.setPreferenceTheme(this);
    super.onCreate(savedInstanceState);

    ActionBar actionBar = getActionBar();
    actionBar.setDisplayHomeAsUpEnabled(true);

    setContentView(R.layout.feed_edit);/*from w w  w  .ja  v  a2s.  c  o  m*/
    setResult(RESULT_CANCELED);

    Intent intent = getIntent();

    mNameEditText = (EditText) findViewById(R.id.feed_title);
    mUrlEditText = (EditText) findViewById(R.id.feed_url);
    mRetrieveFulltextCb = (CheckBox) findViewById(R.id.retrieve_fulltext);
    mFiltersListView = (ListView) findViewById(android.R.id.list);
    View filtersLayout = findViewById(R.id.filters_layout);
    View buttonLayout = findViewById(R.id.button_layout);

    if (intent.getAction().equals(Intent.ACTION_INSERT) || intent.getAction().equals(Intent.ACTION_SEND)) {
        setTitle(R.string.new_feed_title);

        filtersLayout.setVisibility(View.GONE);

        if (intent.hasExtra(Intent.EXTRA_TEXT)) {
            mUrlEditText.setText(intent.getStringExtra(Intent.EXTRA_TEXT));
        }

        restoreInstanceState(savedInstanceState);
    } else if (intent.getAction().equals(Intent.ACTION_EDIT)) {
        setTitle(R.string.edit_feed_title);

        buttonLayout.setVisibility(View.GONE);

        mFiltersCursorAdapter = new FiltersCursorAdapter(this, null);
        mFiltersListView.setAdapter(mFiltersCursorAdapter);
        mFiltersListView.setOnItemLongClickListener(new OnItemLongClickListener() {
            @Override
            public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
                startActionMode(mFilterActionModeCallback);
                mFiltersCursorAdapter.setSelectedFilter(position);
                mFiltersListView.invalidateViews();
                return true;
            }
        });

        getLoaderManager().initLoader(0, null, this);

        if (!restoreInstanceState(savedInstanceState)) {
            Cursor cursor = getContentResolver().query(intent.getData(), FEED_PROJECTION, null, null, null);

            if (cursor.moveToNext()) {
                mPreviousName = cursor.getString(0);
                mNameEditText.setText(mPreviousName);
                mUrlEditText.setText(cursor.getString(1));
                mRetrieveFulltextCb.setChecked(cursor.getInt(2) == 1);
                cursor.close();
            } else {
                cursor.close();
                Crouton.makeText(EditFeedActivity.this, R.string.error, Style.INFO);
                finish();
            }
        }
    }
}

From source file:com.xengar.android.booksearch.ui.BookDetailActivity.java

private void setShareIntent() {
    ImageView ivImage = (ImageView) findViewById(R.id.ivBookCover);
    final TextView tvTitle = (TextView) findViewById(R.id.tvTitle);
    // Get access to the URI for the bitmap
    Uri bmpUri = getLocalBitmapUri(ivImage);
    // Construct a ShareIntent with link to image
    Intent shareIntent = new Intent();
    // Construct a ShareIntent with link to image
    shareIntent.setAction(Intent.ACTION_SEND);
    shareIntent.setType("*/*");
    shareIntent.putExtra(Intent.EXTRA_TEXT, (String) tvTitle.getText());
    shareIntent.putExtra(Intent.EXTRA_STREAM, bmpUri);
    // Launch share menu
    startActivity(Intent.createChooser(shareIntent, "Share Image"));
}

From source file:cn.figo.mydemo.ui.activity.VideoActivity.java

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

    mSettings = new Settings(this);

    //      handle arguments
    mVideoPath = getIntent().getStringExtra("videoPath");

    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
        String scheme = mVideoUri.getScheme();
        if (TextUtils.isEmpty(scheme)) {
            Log.e(TAG, "Null unknown ccheme\n");
            finish();/*ww w  .ja  v  a 2  s.co m*/
            return;
        }
        if (scheme.equals(ContentResolver.SCHEME_ANDROID_RESOURCE)) {
            mVideoPath = mVideoUri.getPath();
        } else if (scheme.equals(ContentResolver.SCHEME_CONTENT)) {
            Log.e(TAG, "Can not resolve content below Android-ICS\n");
            finish();
            return;
        } else {
            Log.e(TAG, "Unknown scheme " + scheme + "\n");
            finish();
            return;
        }
    }

    Intent intent = getIntent();
    String intentAction = intent.getAction();
    if (!TextUtils.isEmpty(intentAction)) {
        if (intentAction.equals(Intent.ACTION_VIEW)) {
            mVideoPath = intent.getDataString();
        } else if (intentAction.equals(Intent.ACTION_SEND)) {
            mVideoUri = intent.getParcelableExtra(Intent.EXTRA_STREAM);
            if (Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
                String scheme = mVideoUri.getScheme();
                if (TextUtils.isEmpty(scheme)) {
                    Log.e(TAG, "Null unknown ccheme\n");
                    finish();
                    return;
                }
                if (scheme.equals(ContentResolver.SCHEME_ANDROID_RESOURCE)) {
                    mVideoPath = mVideoUri.getPath();
                } else if (scheme.equals(ContentResolver.SCHEME_CONTENT)) {
                    Log.e(TAG, "Can not resolve content below Android-ICS\n");
                    finish();
                    return;
                } else {
                    Log.e(TAG, "Unknown scheme " + scheme + "\n");
                    finish();
                    return;
                }
            }
        }
    }

    if (!TextUtils.isEmpty(mVideoPath)) {
        new RecentMediaStorage(this).saveUrlAsync(mVideoPath);
    }

    // init UI
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    ActionBar actionBar = getSupportActionBar();
    mMediaController = new AndroidMediaController(this, false);
    mMediaController.setSupportActionBar(actionBar);

    mToastTextView = (TextView) findViewById(R.id.toast_text_view);
    mHudView = (TableLayout) findViewById(R.id.hud_view);
    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    mRightDrawer = (ViewGroup) findViewById(R.id.right_drawer);

    mDrawerLayout.setScrimColor(Color.TRANSPARENT);

    new RecentMediaStorage(this).saveUrlAsync(mVideoPath);

    // init player
    IjkMediaPlayer.loadLibrariesOnce(null);
    IjkMediaPlayer.native_profileBegin("libijkplayer.so");

    mVideoView = (IjkVideoView) findViewById(R.id.video_view);
    mVideoView.setMediaController(mMediaController);
    mVideoView.setHudView(mHudView);

    mVideoView.toggleAspectRatio();

    if (mVideoPath != null)
        mVideoView.setVideoPath(mVideoPath);
    else if (mVideoUri != null)
        mVideoView.setVideoURI(mVideoUri);
    else {
        Log.e(TAG, "Null Data Source\n");
        finish();
        return;
    }

    initDanmaku();

}

From source file:com.digitalarx.android.files.FileOperationsHelper.java

private Intent createShareWithLinkIntent(String link) {
    Intent intentToShareLink = new Intent(Intent.ACTION_SEND);
    intentToShareLink.putExtra(Intent.EXTRA_TEXT, link);
    intentToShareLink.setType(HTTP.PLAIN_TEXT_TYPE);
    return intentToShareLink;
}

From source file:com.samuelcastro.cordova.InstagramSharePlugin.java

private void shareVideo(String videoString, String captionString) {

    // Create the URI from the media
    File media = new File(this.getRealVideoPathFromURI(Uri.parse(videoString)));
    Uri uri = Uri.fromFile(media);/*from   ww w .  ja v  a2  s  .c om*/

    Intent shareIntent = new Intent(Intent.ACTION_SEND);
    shareIntent.setType("video/*");
    shareIntent.putExtra(Intent.EXTRA_STREAM, uri);
    shareIntent.putExtra(Intent.EXTRA_TEXT, captionString);
    shareIntent.setPackage("com.instagram.android");

    this.cordova.startActivityForResult((CordovaPlugin) this, shareIntent, 12345);

}

From source file:edu.stanford.junction.sample.partyware.ImgurUploadService.java

/**
 * /* w  w w .java 2 s  .  c o  m*/
 * @return a map that contains objects with the following keys:
 * 
 *         delete - the url used to delete the uploaded image (null if
 *         error).
 * 
 *         original - the url to the uploaded image (null if error) The map
 *         is null if error
 */
private Map<String, String> handleSendIntent(final Intent intent) {
    Log.i(this.getClass().getName(), "in handleResponse()");

    Log.d(this.getClass().getName(), intent.toString());
    final Bundle extras = intent.getExtras();
    try {
        //upload a new image
        if (Intent.ACTION_SEND.equals(intent.getAction()) && (extras != null)
                && extras.containsKey(Intent.EXTRA_STREAM)) {

            final Uri uri = (Uri) extras.getParcelable(Intent.EXTRA_STREAM);
            if (uri != null) {
                Log.d(this.getClass().getName(), uri.toString());
                imageLocation = uri;
                final String jsonOutput = readPictureDataAndUpload(uri);
                return parseJSONResponse(jsonOutput);
            }
            Log.e(this.getClass().getName(), "URI null");
        }
    } catch (final Exception e) {
        Log.e(this.getClass().getName(), "Completely unexpected error", e);
    }
    return null;
}

From source file:palamarchuk.smartlife.app.fragments.ProfileFragment.java

private void feedback() {
    Intent sendIntent;/*from w  ww  .ja  v  a 2s  .  co  m*/
    sendIntent = new Intent(Intent.ACTION_SEND);
    sendIntent.putExtra(Intent.EXTRA_EMAIL, new String[] { "support@smartlife.com.kz" });
    sendIntent.putExtra(Intent.EXTRA_SUBJECT, "");
    sendIntent.putExtra(Intent.EXTRA_TEXT, "");
    sendIntent.setType("image/jpeg");

    try {
        startActivity(Intent.createChooser(sendIntent, "Send Mail"));
    } catch (android.content.ActivityNotFoundException ex) {
        Toast.makeText(parentActivity, "There are no email clients installed.", Toast.LENGTH_SHORT).show();
    }
}

From source file:com.codebutler.farebot.activities.AdvancedCardInfoActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    try {//from  ww w .  j ava  2  s .  com
        String xml = Utils.xmlNodeToString(mCard.toXML().getOwnerDocument());
        if (item.getItemId() == R.id.copy_xml) {
            @SuppressWarnings("deprecation")
            ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
            clipboard.setText(xml);
            Toast.makeText(this, "Copied to clipboard.", 5).show();
            return true;

        } else if (item.getItemId() == R.id.share_xml) {
            Intent intent = new Intent(Intent.ACTION_SEND);
            intent.setType("text/plain");
            intent.putExtra(Intent.EXTRA_TEXT, xml);
            startActivity(intent);
            return true;

        } else if (item.getItemId() == android.R.id.home) {
            finish();
            return true;
        }
    } catch (Exception ex) {
        new AlertDialog.Builder(this).setMessage(ex.toString()).show();
    }
    return false;
}