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.bushstar.htmlcoin_android_wallet.ui.RequestCoinsFragment.java

private void handleShare() {
    final Intent intent = new Intent(Intent.ACTION_SEND);
    intent.setType("text/plain");
    intent.putExtra(Intent.EXTRA_TEXT, determineHTMLcoinRequestStr(false));
    startActivity(Intent.createChooser(intent, getString(R.string.request_coins_share_dialog_title)));
}

From source file:com.bushstar.kobocoin_android_wallet.ui.RequestCoinsFragment.java

private void handleShare() {
    final Intent intent = new Intent(Intent.ACTION_SEND);
    intent.setType("text/plain");
    intent.putExtra(Intent.EXTRA_TEXT, determineKobocoinRequestStr(false));
    startActivity(Intent.createChooser(intent, getString(R.string.request_coins_share_dialog_title)));
}

From source file:com.code.android.vibevault.ShowDetailsScreen.java

/** Handle user's long-click selection.
*
*//*from   ww  w  .  j  a v  a2s  . c  om*/
@Override
public boolean onContextItemSelected(MenuItem item) {
    AdapterContextMenuInfo menuInfo = (AdapterContextMenuInfo) item.getMenuInfo();
    if (menuInfo != null) {
        ArchiveSongObj selSong = (ArchiveSongObj) trackList.getAdapter().getItem(menuInfo.position);
        switch (item.getItemId()) {
        case (VibeVault.STREAM_CONTEXT_ID):
            // Start streaming.
            int track = pService.enqueue(selSong);
            pService.playSongFromPlaylist(track);
            break;
        case (VibeVault.DOWNLOAD_SONG):
            selSong.setDownloadShow(show);
            dService.addSong(selSong);
            break;
        case (VibeVault.ADD_SONG_TO_QUEUE):
            pService.enqueue(selSong);
            break;
        case (VibeVault.EMAIL_LINK):
            final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
            emailIntent.setType("plain/text");
            emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT,
                    "Great song on archive.org: " + selSong.toString());
            emailIntent.putExtra(android.content.Intent.EXTRA_TEXT,
                    "Hey,\n\nI found a song you should listen to.  It's called " + selSong.toString()
                            + " and it's off of " + selSong.getShowTitle() + ".  You can get it here: "
                            + selSong.getLowBitRate() + "\n\nSent using VibeVault for Android.");
            startActivity(Intent.createChooser(emailIntent, "Send mail..."));
            break;
        default:
            return false;
        }
        return true;
    }
    return false;
}

From source file:com.bitants.wally.activities.ImageDetailsActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.image_details, menu);

    MenuItem shareMenuItem = menu.findItem(R.id.action_share);

    if (shareMenuItem != null) {
        ShareActionProvider shareActionProvider = (ShareActionProvider) MenuItemCompat
                .getActionProvider(shareMenuItem);
        Intent shareIntent = new Intent(Intent.ACTION_SEND);
        shareIntent.setType("text/plain");
        shareIntent.putExtra(Intent.EXTRA_TEXT, pageUri.toString());
        shareActionProvider.setShareIntent(shareIntent);
        shareMenuItem.setIcon(R.drawable.ic_action_share);
    }/*  w ww .j  a v  a 2  s .  c o m*/

    return super.onCreateOptionsMenu(menu);
}

From source file:ch.blinkenlights.android.vanilla.MediaUtils.java

/**
 * Creates and sends a share intent across the system.
 * @param ctx context to execute resolving on.
 * @param song the song to share.//from ww w. j  av  a  2  s . c o m
 */
public static void shareMedia(Context ctx, Song song) {
    if (song == null || song.path == null)
        return;

    Uri uri = null;
    try {
        uri = FileProvider.getUriForFile(ctx, ctx.getApplicationContext().getPackageName() + ".fileprovider",
                new File(song.path));
    } catch (IllegalArgumentException e) {
        Toast.makeText(ctx, R.string.share_failed, Toast.LENGTH_SHORT).show();
    }

    if (uri == null)
        return; // Fileprovider failed, we can not continue.

    Intent intent = new Intent(Intent.ACTION_SEND);
    intent.setType("audio/*");
    intent.putExtra(Intent.EXTRA_STREAM, uri);
    try {
        ctx.startActivity(Intent.createChooser(intent, ctx.getString(R.string.sendto)));
    } catch (ActivityNotFoundException e) {
        Toast.makeText(ctx, R.string.no_receiving_apps, Toast.LENGTH_SHORT).show();
    }
}

From source file:com.android.talkback.labeling.LabelManagerSummaryActivity.java

private void addExportCustomLabelClickListener() {
    final Button exportLabel = (Button) findViewById(R.id.export_labels);
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR2) {
        exportLabel.setVisibility(View.GONE);
        return;//from   w  ww  .ja  v a 2s . c o m
    }

    exportLabel.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View view) {
            CustomLabelMigrationManager exporter = new CustomLabelMigrationManager(getApplicationContext());
            exporter.exportLabels(new CustomLabelMigrationManager.SimpleLabelMigrationCallback() {
                @Override
                public void onLabelsExported(File file) {
                    if (file == null) {
                        notifyLabelExportFailure();
                        return;
                    }

                    Uri uri = FileProvider.getUriForFile(getApplicationContext(), FILE_AUTHORITY, file);
                    Intent shareIntent = new Intent();
                    shareIntent.setAction(Intent.ACTION_SEND);
                    shareIntent.putExtra(Intent.EXTRA_STREAM, uri);
                    shareIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
                    shareIntent.setType("application/json");

                    String activityTitle = getResources().getString(R.string.label_choose_app_to_export);
                    startActivity(Intent.createChooser(shareIntent, activityTitle));
                }

                @Override
                public void onFail() {
                    notifyLabelExportFailure();
                }
            });
            return;
        }
    });
}

From source file:de.geeksfactory.opacclient.frontend.AccountFragment.java

@Override
public void accountSelected(Account account) {

    svAccount.setVisibility(View.GONE);
    unsupportedErrorView.setVisibility(View.GONE);
    answerErrorView.setVisibility(View.GONE);
    errorView.removeAllViews();//from   w w  w  . j  a  v a  2s . c o m
    llLoading.setVisibility(View.VISIBLE);

    setRefreshing(false);
    supported = true;

    this.account = app.getAccount();
    OpacApi api;
    try {
        api = app.getApi();
    } catch (NullPointerException e) {
        e.printStackTrace();
        return;
    }
    if (api != null && !app.getLibrary().isAccountSupported()) {
        supported = false;
        // Not supported with this api at all
        llLoading.setVisibility(View.GONE);
        unsupportedErrorView.setVisibility(View.VISIBLE);
        tvErrBodyU.setText(R.string.account_unsupported_api);
        btSend.setText(R.string.write_mail);
        btSend.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
                emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[] { "info@opacapp.de" });
                emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT,
                        "Bibliothek " + app.getLibrary().getIdent());
                emailIntent.putExtra(android.content.Intent.EXTRA_TEXT,
                        getResources().getString(R.string.interested_to_help));
                emailIntent.setType("text/plain");
                startActivity(Intent.createChooser(emailIntent, getString(R.string.write_mail)));
            }
        });

    } else if (account.getPassword() == null || account.getPassword().equals("null")
            || account.getPassword().equals("") || account.getName() == null || account.getName().equals("null")
            || account.getName().equals("")) {
        // No credentials entered
        llLoading.setVisibility(View.GONE);
        answerErrorView.setVisibility(View.VISIBLE);
        btPrefs.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(getActivity(), AccountEditActivity.class);
                intent.putExtra(AccountEditActivity.EXTRA_ACCOUNT_ID, app.getAccount().getId());
                startActivity(intent);
            }
        });
        tvErrHeadA.setText("");
        tvErrBodyA.setText(R.string.status_nouser);

    } else {
        // Supported
        Context ctx = getActivity() != null ? getActivity() : OpacClient.getEmergencyContext();
        AccountDataSource adatasource = new AccountDataSource(ctx);
        adatasource.open();
        refreshtime = adatasource.getCachedAccountDataTime(account);
        if (refreshtime > 0) {
            displaydata(adatasource.getCachedAccountData(account), true);
            if (System.currentTimeMillis() - refreshtime > MAX_CACHE_AGE) {
                refresh();
            }
        } else {
            refresh();
        }
        adatasource.close();
    }
}

From source file:com.dwdesign.tweetings.activity.ComposeActivity.java

@Override
public void onActivityResult(final int requestCode, final int resultCode, final Intent intent) {

    switch (requestCode) {
    case REQUEST_SCHEDULE_DATE: {
        if (resultCode == Activity.RESULT_OK) {
            Bundle bundle = intent.getExtras();
            mScheduleDate = bundle.getString(INTENT_KEY_SCHEDULE_DATE_TIME);
        } else {/*from   w ww . j  a  va  2s  .  co m*/
            if (mScheduleDate != null) {
                mScheduleDate = null;
            }
        }
        setMenu();
        break;
    }
    case REQUEST_TAKE_PHOTO: {
        if (resultCode == Activity.RESULT_OK) {
            final File file = new File(mImageUri.getPath());
            if (file.exists()) {
                mIsImageAttached = false;
                mIsPhotoAttached = true;
                mImageThumbnailPreview.setVisibility(View.VISIBLE);
                reloadAttachedImageThumbnail(file);
            } else {
                mIsPhotoAttached = false;
            }
            setMenu();
            boolean isAutoUpload = mPreferences.getBoolean(PREFERENCE_KEY_AUTO_UPLOAD, false);
            if (!isNullOrEmpty(mUploadProvider) && mIsPhotoAttached && isAutoUpload) {
                postMedia();
            }
        }
        break;
    }
    case REQUEST_PICK_IMAGE: {
        if (resultCode == Activity.RESULT_OK) {
            final Uri uri = intent.getData();
            final File file = uri == null ? null : new File(getImagePathFromUri(this, uri));
            if (file != null && file.exists()) {
                mImageUri = Uri.fromFile(file);
                mIsPhotoAttached = false;
                mIsImageAttached = true;
                mImageThumbnailPreview.setVisibility(View.VISIBLE);
                reloadAttachedImageThumbnail(file);
            } else {
                mIsImageAttached = false;
            }
            setMenu();
            boolean isAutoUpload = mPreferences.getBoolean(PREFERENCE_KEY_AUTO_UPLOAD, false);
            if (!isNullOrEmpty(mUploadProvider) && mIsImageAttached && isAutoUpload) {
                postMedia();
            }
        }
        break;
    }
    case REQUEST_SELECT_ACCOUNT: {
        if (resultCode == Activity.RESULT_OK) {
            final Bundle bundle = intent.getExtras();
            if (bundle == null) {
                break;
            }
            final long[] account_ids = bundle.getLongArray(INTENT_KEY_IDS);
            if (account_ids != null) {
                mAccountIds = account_ids;
                if (mInReplyToStatusId <= 0 && !Intent.ACTION_SEND.equals(getIntent().getAction())) {
                    final SharedPreferences.Editor editor = mPreferences.edit();
                    editor.putString(PREFERENCE_KEY_COMPOSE_ACCOUNTS,
                            ArrayUtils.toString(mAccountIds, ',', false));
                    editor.commit();
                }
                mColorIndicator.setColor(getAccountColors(this, account_ids));
            }
        }
        break;
    }
    case REQUEST_EDIT_IMAGE: {
        if (resultCode == Activity.RESULT_OK) {
            final Uri uri = intent.getData();
            final File file = uri == null ? null : new File(getImagePathFromUri(this, uri));
            if (file != null && file.exists()) {
                mImageUri = Uri.fromFile(file);
                reloadAttachedImageThumbnail(file);
            } else {
                break;
            }
            setMenu();
        }
        break;
    }
    case REQUEST_EXTENSION_COMPOSE: {
        if (resultCode == Activity.RESULT_OK) {
            final Bundle extras = intent.getExtras();
            if (extras == null) {
                break;
            }
            final String text = extras.getString(INTENT_KEY_TEXT);
            final String append = extras.getString(INTENT_KEY_APPEND_TEXT);
            if (text != null) {
                mEditText.setText(text);
                mText = parseString(mEditText.getText());
            } else if (append != null) {
                mEditText.append(append);
                mText = parseString(mEditText.getText());
            }
        }
        break;
    }
    case ACTION_REQUEST_FEATHER:
        if (resultCode == RESULT_OK) {
            final Uri uri = intent.getData();
            final File file = uri == null ? null : new File(getImagePathFromUri(this, uri));
            if (file != null && file.exists()) {
                mImageUri = Uri.fromFile(file);
                reloadAttachedImageThumbnail(file);
            } else {
                break;
            }
            setMenu();
        }
        break;
    }

}

From source file:pffy.mobile.flax.FlaxActivity.java

private boolean sendDetailsByIntent() {

    if (this.mExportFacts.equals("") || this.mExportFacts == null) {
        // do not send empty files
        return false;
    }/*from   w  ww  .  j  a  v a 2 s  .c  o  m*/

    // boilerplate intent code
    Intent sendIntent = new Intent();
    sendIntent.setAction(Intent.ACTION_SEND);
    sendIntent.putExtra(Intent.EXTRA_TEXT, this.mExportFacts);
    sendIntent.setType(HTTP.PLAIN_TEXT_TYPE);
    startActivity(Intent.createChooser(sendIntent, getResources().getString(R.string.msg_shareto)));

    return true;
}

From source file:android.support.v7.widget.ShareActionProvider.java

/**
 * Sets an intent with information about the share action. Here is a
 * sample for constructing a share intent:
 * <p>//from   w  w w . ja  v  a  2  s. c  om
 * <pre>
 * <code>
 *  Intent shareIntent = new Intent(Intent.ACTION_SEND);
 *  shareIntent.setType("image/*");
 *  Uri uri = Uri.fromFile(new File(getFilesDir(), "foo.jpg"));
 *  shareIntent.putExtra(Intent.EXTRA_STREAM, uri.toString());
 * </pre>
 * </code>
 * </p>
 *
 * @param shareIntent The share intent.
 *
 * @see Intent#ACTION_SEND
 * @see Intent#ACTION_SEND_MULTIPLE
 */
public void setShareIntent(Intent shareIntent) {
    if (shareIntent != null) {
        final String action = shareIntent.getAction();
        if (Intent.ACTION_SEND.equals(action) || Intent.ACTION_SEND_MULTIPLE.equals(action)) {
            updateIntent(shareIntent);
        }
    }
    ActivityChooserModel dataModel = ActivityChooserModel.get(mContext, mShareHistoryFileName);
    dataModel.setIntent(shareIntent);
}