Example usage for android.content Intent EXTRA_TEXT

List of usage examples for android.content Intent EXTRA_TEXT

Introduction

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

Prototype

String EXTRA_TEXT

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

Click Source Link

Document

A constant CharSequence that is associated with the Intent, used with #ACTION_SEND to supply the literal data to be sent.

Usage

From source file:com.actionbarsherlock.sample.hcgallery.MainActivity.java

PendingIntent getDialogPendingIntent(String dialogText) {
    return PendingIntent.getActivity(this, dialogText.hashCode(), // Otherwise previous PendingIntents with the same
            // requestCode may be overwritten.
            new Intent(ACTION_DIALOG).putExtra(Intent.EXTRA_TEXT, dialogText)
                    .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK),
            0);/*www  .j a  v a2 s  .  co  m*/
}

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);
    }/*ww w. j  a va2  s  .  c om*/

    return super.onCreateOptionsMenu(menu);
}

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

/** Handle user's long-click selection.
*
*//*w w w.j a  v a 2 s. 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:io.github.protino.codewatch.ui.LeaderboardFragment.java

@Override
public void onItemSelected(String userId) {
    ActivityOptionsCompat options = ActivityOptionsCompat.makeSceneTransitionAnimation(getActivity());
    Intent intent = new Intent(context, ProfileActivity.class);
    intent.putExtra(Intent.EXTRA_TEXT, userId);
    startActivity(intent, options.toBundle());
}

From source file:in.shick.diode.submit.SubmitLinkActivity.java

private boolean lastDitchExtractProperties(Bundle extras, SubmissionProperties properties) {
    if (extras != null) {
        // find the most likely submission URL since some
        // programs share more than the URL
        // the most likely is considered to be the longest
        // string token with a URI scheme of http or https
        StringBuilder titleBuilder = new StringBuilder();
        String rawText = extras.getString(Intent.EXTRA_TEXT);
        StringTokenizer extraTextTokenizer = new StringTokenizer(rawText);
        Uri bestUri = Uri.parse("");
        while (extraTextTokenizer.hasMoreTokens()) {
            Uri uri = Uri.parse(extraTextTokenizer.nextToken());
            if (!"http".equalsIgnoreCase(uri.getScheme()) && !"https".equalsIgnoreCase(uri.getScheme())) {
                titleBuilder.append(uri.toString()).append(' ');
                continue;
            }//from  ww  w . ja v a  2s .co m
            if (uri.toString().length() > bestUri.toString().length()) {
                bestUri = uri;
            }
        }

        properties = new SubmissionProperties();
        properties.url = bestUri.toString();
        properties.title = titleBuilder.toString();

        return true;
    }

    return false;
}

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 w w . ja  v a2 s .co  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:com.codeskraps.sbrowser.home.SBrowserActivity.java

@SuppressLint("NewApi")
@Override//from  www.j av  a  2  s.  c om
public boolean onContextItemSelected(MenuItem item) {
    Log.v(TAG, "onContextItemSelected");

    WebView.HitTestResult result = webView.getHitTestResult();
    Log.d(TAG, "result: " + result.getExtra());
    Intent sharingIntent = new Intent(Intent.ACTION_SEND);

    switch (item.getItemId()) {
    case R.id.itemSaveImage:
    case R.id.itemSaveLink:

        try {
            DownloadManager dm = (DownloadManager) getSystemService(DOWNLOAD_SERVICE);
            Request request = new Request(Uri.parse(result.getExtra()));
            dm.enqueue(request);
        } catch (Exception e) {
            Toast.makeText(this, "sBrowser - Error saving...", Toast.LENGTH_SHORT).show();
            Log.d(TAG, "Erro Downloading: " + e);
        }
        break;

    case R.id.itemCopyLink:

        if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) {
            ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
            clipboard.setText(result.getExtra());
        } else {
            android.content.ClipboardManager newClipboard = (android.content.ClipboardManager) getSystemService(
                    CLIPBOARD_SERVICE);
            ClipData clip = ClipData.newPlainText("label", result.getExtra());
            newClipboard.setPrimaryClip(clip);
        }

        break;

    case R.id.itemShareLink:

        try {
            sharingIntent.setType("text/html");
            sharingIntent.putExtra(Intent.EXTRA_TEXT, result.getExtra());
            startActivity(Intent.createChooser(sharingIntent, "Share using..."));
        } catch (Exception e) {
            e.printStackTrace();
            Log.d(TAG, "Erro Sharing link: " + e);
        }

        break;

    case R.id.itemShareImage:

        try {
            sharingIntent.setType("image/*");
            sharingIntent.putExtra(Intent.EXTRA_STREAM, result.getExtra());
            startActivity(Intent.createChooser(sharingIntent, "Share image using..."));
        } catch (Exception e) {
            e.printStackTrace();
            Log.d(TAG, "Erro Sharing Image: " + e);
        }

        break;
    }

    return super.onContextItemSelected(item);
}

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   ww  w  .  j  av a2 s .com
    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.brq.wallet.activity.receive.ReceiveCoinsActivity.java

public void shareRequest(View view) {
    Intent s = new Intent(android.content.Intent.ACTION_SEND);
    s.setType("text/plain");
    if (CurrencyValue.isNullOrZero(_amount)) {
        s.putExtra(Intent.EXTRA_SUBJECT, getResources().getString(R.string.bitcoin_address_title));
        s.putExtra(Intent.EXTRA_TEXT, getBitcoinAddress());
        startActivity(Intent.createChooser(s, getResources().getString(R.string.share_bitcoin_address)));
    } else {// w w  w . j a  v  a  2 s.co m
        s.putExtra(Intent.EXTRA_SUBJECT, getResources().getString(R.string.payment_request));
        s.putExtra(Intent.EXTRA_TEXT, getPaymentUri());
        startActivity(Intent.createChooser(s, getResources().getString(R.string.share_payment_request)));
    }
}

From source file:net.mEmoZz.PopMovies.frags.DetailFragment.java

private Intent createShareForecastIntent() {
    Intent shareIntent = new Intent(Intent.ACTION_SEND);
    shareIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
    shareIntent.setType("text/plain");
    shareIntent.putExtra(Intent.EXTRA_TEXT, "Check this movie: " + titleEndPoint + " from #Popular_Movies_APP");
    return shareIntent;
}