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:org.geek.utils.ApplicationUtils.java

/**
 * Share a page.//w  ww.ja v  a 2 s  . co  m
 * @param activity The parent activity.
 * @param title The page title.
 * @param url The page url.
 */
public static void sharePage(Activity activity, String title, String url) {
    Intent shareIntent = new Intent(Intent.ACTION_SEND);

    shareIntent.setType("text/plain");
    shareIntent.putExtra(Intent.EXTRA_TEXT, url);
    shareIntent.putExtra(Intent.EXTRA_SUBJECT, title);

    try {
        activity.startActivity(
                Intent.createChooser(shareIntent, activity.getString(R.string.Main_ShareChooserTitle)));
    } catch (android.content.ActivityNotFoundException ex) {
        // if no app handles it, do nothing
    }
}

From source file:com.commonsware.android.tte.DocumentStorageService.java

@Override
protected void onHandleIntent(Intent intent) {
    if (Intent.ACTION_OPEN_DOCUMENT.equals(intent.getAction())) {
        load(intent.getData());//from  ww  w .  j ava  2 s  .  com
    } else if (Intent.ACTION_EDIT.equals(intent.getAction())) {
        save(intent.getData(), intent.getStringExtra(Intent.EXTRA_TEXT),
                intent.getBooleanExtra(EXTRA_CLOSING, false));
    }
}

From source file:com.jakebasile.android.linkshrink.ShortenUrl.java

@Override
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    reshare = false;/*from w  ww .  jav  a2  s  .c  o  m*/
    Intent intent = getIntent();
    Bundle extras = intent.getExtras();
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getBaseContext());
    shorten(prefs, extras.getString(Intent.EXTRA_TEXT));
}

From source file:eu.thecoder4.gpl.pleftdroid.HandleLinksActivity.java

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    TextView tv = new TextView(this);

    tv.setText("Verifying Link...");
    setContentView(tv);/* w w w  .  j  a va2  s.c o m*/

    Intent intent = getIntent();
    if (intent.getAction().equals("android.intent.action.VIEW")) {
        try {
            Uri uri = getIntent().getData();
            theurl = uri.toString();

        } catch (Exception e) {
            Toast.makeText(this, R.string.toast_couldnotopenurl, Toast.LENGTH_LONG).show();
        }
    } else if (Intent.ACTION_SEND.equals(intent.getAction())) {

        Bundle extras = intent.getExtras();
        theurl = extras.getCharSequence(Intent.EXTRA_TEXT).toString();
    } else {
        theurl = "";
    }
    //Toast.makeText(this, "The URL  =  "+theurl, Toast.LENGTH_LONG).show();

    // Parse the URL
    // VERIFICATION: verify?id=&u=&p=
    // INVITATION: a?id=&u=&p=
    if (theurl.indexOf("?") < 0 && theurl.indexOf("/verify?") < 0 && theurl.indexOf("/a?") < 0) {
        Toast.makeText(this, R.string.toast_linknotsupp, Toast.LENGTH_LONG).show();
        finish();
    } else {
        Map<String, String> arr = PleftBroker.getParamsFromURL(theurl);

        pserver = arr.get("pserver");
        if (arr.get("id") != null) {
            aid = Integer.parseInt(arr.get("id"));
        } else {
            aid = 0;
        }
        vcode = arr.get("p");
        user = arr.get("u");
        if (aid == 0 || vcode == null || user == null) {
            Toast.makeText(this, R.string.toast_shlinknotvalid, Toast.LENGTH_LONG).show();
            finish();
        } else { // we have a valid Link

            handleLnk = new Runnable() {
                @Override
                public void run() {
                    handleLink();
                }
            };
            Thread thread = new Thread(null, handleLnk, "Handlethrd");
            thread.start();
        } // End - if Link is Valid
    }
}

From source file:com.coinblesk.client.ui.dialogs.ReceiveDialogFragment.java

@Nullable
@Override//from w w  w  .ja  v a 2  s. c om
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
        @Nullable Bundle savedInstanceState) {
    final String bitcoinUriString = this.getArguments().getString(BITCOIN_URI_KEY);

    try {
        final BitcoinURI bitcoinURI = new BitcoinURI(bitcoinUriString);
        final View view = inflater.inflate(R.layout.fragment_receive_alertdialog, null);
        view.findViewById(R.id.receive_email_touch_area).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
                emailIntent.setType("text/html");
                emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT,
                        String.format(getString(R.string.payment_request_html_subject)));
                emailIntent.putExtra(android.content.Intent.EXTRA_TEXT,
                        Html.fromHtml(String.format(getString(R.string.payment_request_html_content),
                                bitcoinUriString, bitcoinURI.getAmount().toFriendlyString(),
                                bitcoinURI.getAddress())));
                startActivity(Intent.createChooser(emailIntent, "Email:"));
            }
        });

        view.findViewById(R.id.receive_qrcode_touch_area).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                QrDialogFragment.newInstance(bitcoinURI).show(getFragmentManager(), "qr-fragment");
            }
        });

        view.findViewById(R.id.receive_contactless_touch_area).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent action = new Intent(Constants.START_SERVERS_ACTION);
                action.putExtra(BITCOIN_URI_KEY, bitcoinUriString);
                LocalBroadcastManager.getInstance(getActivity()).sendBroadcast(action);
            }
        });

        return view;
    } catch (BitcoinURIParseException e) {
        Log.e(TAG, "Could not parse Bitcoin URI: ", e);
    }
    return null;
}

From source file:de.jamoo.muzei.WallSource.java

@Override
public void onCustomCommand(int id) {
    super.onCustomCommand(id);

    if (id == COMMAND_ID_SHARE) {
        Artwork currentArtwork = getCurrentArtwork();
        Intent shareIntent = new Intent(Intent.ACTION_SEND);
        shareIntent.setType("text/plain");

        Uri artUrl = currentArtwork.getImageUri();
        if (DEBUG)
            Log.d(TAG, "artUrl: " + artUrl);

        String author = currentArtwork.getByline();
        if (DEBUG)
            Log.d(TAG, "author: " + author);

        String playUrl = "http://play.google.com/store/apps/details?id=" + getPackageName();
        if (DEBUG)
            Log.d(TAG, "playUrl: " + playUrl);

        shareIntent.putExtra(Intent.EXTRA_TEXT,
                "My wallpaper today is " + currentArtwork.getTitle() + " by " + author + " \n" + artUrl + " \n"
                        + "from the " + getString(R.string.app_name) + " app\n"
                        + "Get it now on the PlayStore! " + playUrl);

        shareIntent = Intent.createChooser(shareIntent, "Share Wallpaper");
        shareIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        startActivity(shareIntent);/*w  w w  .  j  a v a 2s  .com*/
    }
}

From source file:be.vbsteven.bmtodesk.ShareActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    setTheme(android.R.style.Theme_Light_NoTitleBar);
    super.onCreate(savedInstanceState);
    setContentView(R.layout.share);/*from  w ww.  j a v a  2s .  co m*/

    handler = new Handler();

    // if the user has not configured his credentials yet, show registration wizard
    if (!Global.hasUserCredentials(this)) {
        startActivity(new Intent(this, RegistrationActivity.class));
        finish();
    }

    // check if we are called with a share intent
    if (getIntent().getAction() != null && getIntent().getAction().equals("android.intent.action.SEND")) {
        if (getIntent().hasExtra(Intent.EXTRA_TEXT)) {
            String value = getIntent().getStringExtra(Intent.EXTRA_TEXT);
            value = sanitizeValue(value);

            EditText titleText = (EditText) findViewById(R.id.et_title);
            EditText urlText = (EditText) findViewById(R.id.et_url);

            titleText.setText(value);
            urlText.setText(stripFromTweet(value));
        }
    }

    Button button = (Button) findViewById(R.id.but_send);
    button.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            String title = ((EditText) findViewById(R.id.et_title)).getText().toString();
            String url = ((EditText) findViewById(R.id.et_url)).getText().toString();
            if (validateInput(title, url)) {
                sendToServer(title, url);
            }
        }

    });

    // if fastsharing is on don't bother asking the user for a title
    if (Global.isFastSharing(this)) {
        String url = ((EditText) findViewById(R.id.et_url)).getText().toString();
        if (validateInput(url, url)) {
            sendToServer(url, url);
        }
    }
}

From source file:com.galois.qrstream.lib.DecodeThread.java

private Intent buildIntent(Job message) throws IOException {
    Intent i = new Intent();
    i.setAction(Intent.ACTION_SEND);/*ww w  . j  a va 2s  .c om*/
    i.addCategory(Intent.CATEGORY_DEFAULT);
    String mimeType = message.getMimeType();
    i.setType(mimeType);

    if (mimeType.equals("text/plain")) {
        String msg = new String(message.getData());
        i.putExtra(Intent.EXTRA_TEXT, msg);
    } else {
        // content that is not text uses the filesystem to store the data
        // (when sharing with a new local app)
        File dataLoc = storeData(message);

        if (mimeType.startsWith("image/")) {
            String path = Images.Media.insertImage(context.getContentResolver(), dataLoc.getPath(),
                    message.getTitle(), null);
            Uri imageUri = Uri.parse(path);
            i.putExtra(Intent.EXTRA_STREAM, imageUri);

            // we can delete the temporary location in this case, since the file has been saved
            // to the media store.
            // In the other cases, the receiver has to handle the content of the temp file before
            // it can be deleted -- but we will never know if/when that happens.
            dataLoc.delete();
        } else if (mimeType.equals(Constants.MIME_TYPE_TEXT_NOTE)) {
            String json = new String(message.getData());
            try {
                JSONObject note = new JSONObject(json);
                i.putExtra(Intent.EXTRA_TEXT, note.getString(Intent.EXTRA_TEXT));
                i.putExtra(Intent.EXTRA_SUBJECT, note.getString(Intent.EXTRA_SUBJECT));
                i.setType("text/plain");
            } catch (JSONException e) {
                e.printStackTrace();
            }
        } else {
            i.putExtra(Intent.EXTRA_STREAM, dataLoc.toURI());
        }
    }
    return i;
}

From source file:net.bible.android.control.page.PageControl.java

/** send the current verse via social applications installed on user's device
 *//*from  w w  w.  j  ava 2 s  . c o  m*/
public void shareVerse() {
    try {
        Book book = getCurrentPageManager().getCurrentPage().getCurrentDocument();
        Key key = getCurrentPageManager().getCurrentPage().getSingleKey();

        String text = key.getName() + "\n" + SwordContentFacade.getInstance().getCanonicalText(book, key);

        Intent sendIntent = new Intent(Intent.ACTION_SEND);
        sendIntent.setType("text/plain");

        sendIntent.putExtra(Intent.EXTRA_TEXT, text);
        // subject is used when user chooses to send verse via e-mail
        sendIntent.putExtra(Intent.EXTRA_SUBJECT,
                BibleApplication.getApplication().getText(R.string.share_verse_subject));

        Activity activity = CurrentActivityHolder.getInstance().getCurrentActivity();
        activity.startActivity(Intent.createChooser(sendIntent, activity.getString(R.string.share_verse)));

    } catch (Exception e) {
        Log.e(TAG, "Error sharing verse", e);
        Dialogs.getInstance().showErrorMsg("Error sharing verse");
    }
}

From source file:com.bellman.bible.android.control.page.PageControl.java

/** send the current verse via social applications installed on user's device
 *//*from   w w w .  j  a va  2s . co m*/
public void shareVerse(VerseRange verseRange) {
    try {
        Book book = getCurrentPageManager().getCurrentPage().getCurrentDocument();

        String text = verseRange.getName() + "\n"
                + SwordContentFacade.getInstance().getCanonicalText(book, verseRange);

        Intent sendIntent = new Intent(Intent.ACTION_SEND);
        sendIntent.setType("text/plain");

        sendIntent.putExtra(Intent.EXTRA_TEXT, text);
        // subject is used when user chooses to send verse via e-mail
        sendIntent.putExtra(Intent.EXTRA_SUBJECT,
                CurrentActivityHolder.getInstance().getApplication().getText(R.string.share_verse_subject));

        Activity activity = CurrentActivityHolder.getInstance().getCurrentActivity();
        activity.startActivity(Intent.createChooser(sendIntent, activity.getString(R.string.share_verse)));

    } catch (Exception e) {
        Log.e(TAG, "Error sharing verse", e);
        Dialogs.getInstance().showErrorMsg("Error sharing verse");
    }
}