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.kuacm.expo2013.ui.SessionDetailActivity.java

/** Handle "share" title-bar action. */
public void onShareClick(View v) {
    // TODO: consider bringing in shortlink to session
    final String shareString = getString(R.string.share_template, mTitleString);

    final Intent intent = new Intent(Intent.ACTION_SEND);
    intent.setType("text/plain");
    intent.putExtra(Intent.EXTRA_TEXT, shareString);

    startActivity(Intent.createChooser(intent, getText(R.string.title_share)));
}

From source file:com.google.android.apps.iosched.ui.SessionDetailActivity.java

/** Handle "share" title-bar action. */
public void onShareClick(View v) {
    // TODO: consider bringing in shortlink to session
    final String shareString = getString(R.string.share_template, mTitleString, mHashtag);

    final Intent intent = new Intent(Intent.ACTION_SEND);
    intent.setType("text/plain");
    intent.putExtra(Intent.EXTRA_TEXT, shareString);

    startActivity(Intent.createChooser(intent, getText(R.string.title_share)));
}

From source file:net.bytten.comicviewer.ComicViewerActivity.java

public void shareComicLink() {
    Intent intent = new Intent(Intent.ACTION_SEND, null);
    intent.setType("text/plain");
    intent.putExtra(Intent.EXTRA_TEXT, getCurrentComicUrl());
    startActivity(Intent.createChooser(intent, "Share Link..."));
}

From source file:com.irccloud.android.activity.ImageViewerActivity.java

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

    if (getIntent() != null && getIntent().getDataString() != null) {
        Intent intent = new Intent(Intent.ACTION_SEND, Uri.parse(
                getIntent().getDataString().replace(getResources().getString(R.string.IMAGE_SCHEME), "http")));
        intent.setType("text/plain");
        intent.putExtra(Intent.EXTRA_TEXT,
                getIntent().getDataString().replace(getResources().getString(R.string.IMAGE_SCHEME), "http"));
        intent.putExtra(ShareCompat.EXTRA_CALLING_PACKAGE, getPackageName());
        intent.putExtra(ShareCompat.EXTRA_CALLING_ACTIVITY,
                getPackageManager().getLaunchIntentForPackage(getPackageName()).getComponent());
        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET | Intent.FLAG_ACTIVITY_NEW_TASK);

        MenuItem shareItem = menu.findItem(R.id.action_share);
        ShareActionProviderHax share = (ShareActionProviderHax) MenuItemCompat.getActionProvider(shareItem);
        share.onShareActionProviderSubVisibilityChangedListener = this;
        share.setShareIntent(intent);/*from   www . j  a  v a2s  .com*/
    }
    return true;
}

From source file:com.fa.imaged.activity.DetailActivityV2.java

@Override
public void onClick(View v) {
    switch (v.getId()) {
    case R.id.detail_like:
        if (detailImageLoaderv2.user_has_liked) {
            HeartPostTask liker = new HeartPostTask(detailImageLoaderv2, false, 0);
            liker.execute();//w ww. j  a  va2s  .  c  o m
            try {
                detailImageLoaderv2 = liker.get();
            } catch (InterruptedException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (ExecutionException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            if (!detailImageLoaderv2.user_has_liked) {
                Drawable myIcon = getResources().getDrawable(R.drawable.ic_like);
                myIcon.setColorFilter(0, PorterDuff.Mode.SRC_ATOP);
                detailLikeStatus.setImageDrawable(myIcon);
            }
            detailLikeCounts.setText(String.valueOf(detailImageLoaderv2.liker_count));
        } else {
            animatePhotoLike();
            HeartPostTask liker = new HeartPostTask(detailImageLoaderv2, true, 0);
            liker.execute();
            try {
                detailImageLoaderv2 = liker.get();
            } catch (InterruptedException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (ExecutionException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            if (detailImageLoaderv2.user_has_liked) {
                Drawable myIcon = getResources().getDrawable(R.drawable.ic_like);
                myIcon.setColorFilter(Color.RED, PorterDuff.Mode.SRC_ATOP);
                detailLikeStatus.setImageDrawable(myIcon);
            }
            detailLikeCounts.setText(String.valueOf(detailImageLoaderv2.liker_count));

        }
        break;
    case R.id.detail_likeCounts:
        Intent i = new Intent(getBaseContext(), LikersActivity.class);
        i.putExtra("media_id", detailImageLoaderv2.id);
        i.putExtra("title", "Likers " + "(" + detailImageLoaderv2.liker_count + ")");
        startActivity(i);
        break;
    case R.id.detail_share:
        Intent shareIntent = new Intent();
        Uri uri = null;

        // Create share intent as described above
        if (!detailImageLoaderv2.video) {
            Drawable mDrawable = detailImageV2.getDrawable();
            Bitmap mBitmap = ((BitmapDrawable) mDrawable).getBitmap();
            String path = Images.Media.insertImage(getContentResolver(), mBitmap, detailImageLoaderv2.full_name,
                    detailImageLoaderv2.caption);
            uri = Uri.parse(path);
        } else {

        }
        shareIntent.setAction(Intent.ACTION_SEND);
        shareIntent.putExtra(Intent.EXTRA_STREAM, uri);
        shareIntent.putExtra(Intent.EXTRA_TEXT, detailImageLoaderv2.caption
                + getResources().getString(R.string.share_postby) + detailImageLoaderv2.username);
        startActivity(Intent.createChooser(shareIntent, getResources().getString(R.string.share_to)));
        break;
    case R.id.detail_user_pic:
        viewProfile(this, detailImageLoaderv2);

    }

}

From source file:gr.scify.newsum.ui.ViewActivity.java

private void Sendmail() {
    TextView title = (TextView) findViewById(R.id.title);
    String emailSubject = title.getText().toString();

    // track the Send mail action
    if (getAnalyticsPref()) {
        EasyTracker.getTracker().sendEvent(SHARING_ACTION, "Send Mail", emailSubject, 0l);
    }//  www . ja  va  2s  . c o m
    final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
    emailIntent.setType("text/html");
    emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "NewSum app : " + emailSubject);
    emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, Html.fromHtml(sText));
    startActivity(Intent.createChooser(emailIntent, "Email:"));
}

From source file:com.kd.filmstrip.DetailActivityV2.java

@Override
public void onClick(View v) {
    switch (v.getId()) {
    case R.id.detail_like:
        if (detailImageLoaderv2.user_has_liked) {
            HeartPostTask liker = new HeartPostTask(detailImageLoaderv2, false, 0);
            liker.execute();//w ww  .  j ava2 s  .  co  m
            try {
                detailImageLoaderv2 = liker.get();
            } catch (InterruptedException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (ExecutionException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            if (!detailImageLoaderv2.user_has_liked) {
                Drawable myIcon = getResources().getDrawable(R.drawable.ic_like);
                myIcon.setColorFilter(0, PorterDuff.Mode.SRC_ATOP);
                detailLikeStatus.setImageDrawable(myIcon);
            }
            detailLikeCounts.setText(String.valueOf(detailImageLoaderv2.liker_count));
        } else {
            animatePhotoLike();
            HeartPostTask liker = new HeartPostTask(detailImageLoaderv2, true, 0);
            liker.execute();
            try {
                detailImageLoaderv2 = liker.get();
            } catch (InterruptedException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (ExecutionException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            if (detailImageLoaderv2.user_has_liked) {
                Drawable myIcon = getResources().getDrawable(R.drawable.ic_like);
                myIcon.setColorFilter(Color.RED, PorterDuff.Mode.SRC_ATOP);
                detailLikeStatus.setImageDrawable(myIcon);
            }
            detailLikeCounts.setText(String.valueOf(detailImageLoaderv2.liker_count));

        }
        break;
    case R.id.detail_likeCounts:
        Intent i = new Intent(getBaseContext(), LikersActivity.class);
        i.putExtra("media_id", detailImageLoaderv2.id);
        i.putExtra("title", "Likers " + "(" + detailImageLoaderv2.liker_count + ")");
        startActivity(i);
        break;
    case R.id.detail_share:
        Intent shareIntent = new Intent();
        Uri uri = null;

        // Create share intent as described above
        if (!detailImageLoaderv2.video) {
            Drawable mDrawable = detailImageV2.getDrawable();
            Bitmap mBitmap = ((BitmapDrawable) mDrawable).getBitmap();
            String path = Images.Media.insertImage(getContentResolver(), mBitmap, detailImageLoaderv2.full_name,
                    detailImageLoaderv2.caption);
            uri = Uri.parse(path);
        } else {

        }
        shareIntent.setAction(Intent.ACTION_SEND);
        shareIntent.putExtra(Intent.EXTRA_STREAM, uri);
        shareIntent.putExtra(Intent.EXTRA_TEXT,
                detailImageLoaderv2.caption + " Posted by @" + detailImageLoaderv2.username);
        startActivity(Intent.createChooser(shareIntent, "Share To"));
        break;
    case R.id.detail_user_pic:
        viewProfile(this, detailImageLoaderv2);

    }

}

From source file:ch.luklanis.esscan.history.HistoryActivity.java

private Intent createShareIntent(String mime, Uri dtaFileUri) {
    String[] recipients = new String[] { PreferenceManager.getDefaultSharedPreferences(this)
            .getString(PreferencesActivity.KEY_EMAIL_ADDRESS, "") };
    String subject = getResources().getString(R.string.history_share_as_dta_title);
    String text = String.format(getResources().getString(R.string.history_share_as_dta_summary),
            dtaFileUri.getPath());/*  www  . j a  v a2  s .  c  o  m*/

    Intent intent = new Intent(Intent.ACTION_SEND, Uri.parse("mailto:"));
    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
    intent.setType(mime);

    intent.putExtra(Intent.EXTRA_EMAIL, recipients);
    intent.putExtra(Intent.EXTRA_SUBJECT, subject);
    intent.putExtra(Intent.EXTRA_TEXT, text);

    intent.putExtra(Intent.EXTRA_STREAM, dtaFileUri);

    return intent;
}

From source file:com.balakrish.gpstracker.WaypointsListActivity.java

/**
 * Handle activity menu/* w  ww.j a v  a2s. c om*/
 */
@Override
public boolean onContextItemSelected(MenuItem item) {

    AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();

    final long waypointId = waypointsArrayAdapter.getItem((int) info.id).getId();

    Cursor tmpCursor;
    String sql;

    switch (item.getItemId()) {

    case 0:

        // update waypoint in db
        updateWaypoint(waypointId);

        return true;

    case 1:

        deleteWaypoint(waypointId);

        return true;

    case 2:

        // email waypoint data using default email client

        String elevationUnit = app.getPreferences().getString("elevation_units", "m");
        String elevationUnitLocalized = Utils.getLocalizedElevationUnit(this, elevationUnit);

        sql = "SELECT * FROM waypoints WHERE _id=" + waypointId + ";";
        tmpCursor = app.getDatabase().rawQuery(sql, null);
        tmpCursor.moveToFirst();

        double lat1 = tmpCursor.getDouble(tmpCursor.getColumnIndex("lat")) / 1E6;
        double lng1 = tmpCursor.getDouble(tmpCursor.getColumnIndex("lng")) / 1E6;

        String messageBody = getString(R.string.title) + ": "
                + tmpCursor.getString(tmpCursor.getColumnIndex("title")) + "\n\n" + getString(R.string.lat)
                + ": " + Utils.formatLat(lat1, 0) + "\n" + getString(R.string.lng) + ": "
                + Utils.formatLng(lng1, 0) + "\n" + getString(R.string.elevation) + ": "
                + Utils.formatElevation(tmpCursor.getFloat(tmpCursor.getColumnIndex("elevation")),
                        elevationUnit)
                + elevationUnitLocalized + "\n\n" + "http://maps.google.com/?ll=" + lat1 + "," + lng1 + "&z=10";

        tmpCursor.close();

        final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);

        emailIntent.setType("plain/text");
        emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT,
                getResources().getString(R.string.email_subject_waypoint));
        emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, messageBody);

        this.startActivity(Intent.createChooser(emailIntent, getString(R.string.sending_email)));

        return true;

    case 3:

        this.showOnMap(waypointId);

        return true;

    case 4:

        // TODO: use a thread for online sync

        // sync one waypoint data with remote server

        // create temp waypoint from current record
        Waypoint wp = Waypoints.get(app.getDatabase(), waypointId);

        try {

            // preparing query string for calling web service
            String lat = Location.convert(wp.getLocation().getLatitude(), 0);
            String lng = Location.convert(wp.getLocation().getLongitude(), 0);
            String title = URLEncoder.encode(wp.getTitle());

            String userName = app.getPreferences().getString("user_name", "");
            String userPassword = app.getPreferences().getString("user_password", "");
            String sessionValue = userName + "@" + Utils.md5("aripuca_session" + userPassword);

            if (userName.equals("") || userPassword.equals("")) {
                Toast.makeText(WaypointsListActivity.this, R.string.username_or_password_required,
                        Toast.LENGTH_SHORT).show();
                return false;
            }

            String queryString = "?do=ajax_map_handler&aripuca_session=" + sessionValue
                    + "&action=add_point&lat=" + lat + "&lng=" + lng + "&z=16&n=" + title + "&d=AndroidSync";

            // http connection
            HttpClient httpClient = new DefaultHttpClient();
            HttpContext localContext = new BasicHttpContext();
            HttpGet httpGet = new HttpGet(
                    app.getPreferences().getString("online_sync_url", "http://tracker.aripuca.com")
                            + queryString);
            HttpResponse response = httpClient.execute(httpGet, localContext);

            ByteArrayOutputStream outstream = new ByteArrayOutputStream();
            response.getEntity().writeTo(outstream);

            // parsing JSON return
            JSONObject jsonObject = new JSONObject(outstream.toString());

            Toast.makeText(WaypointsListActivity.this, jsonObject.getString("message").toString(),
                    Toast.LENGTH_SHORT).show();

        } catch (ClientProtocolException e) {
            Toast.makeText(WaypointsListActivity.this, "ClientProtocolException: " + e.getMessage(),
                    Toast.LENGTH_SHORT).show();
        } catch (IOException e) {
            Toast.makeText(WaypointsListActivity.this, "IOException " + e.getMessage(), Toast.LENGTH_SHORT)
                    .show();
        } catch (JSONException e) {
            Toast.makeText(WaypointsListActivity.this, "JSONException " + e.getMessage(), Toast.LENGTH_SHORT)
                    .show();
        }

        return true;

    default:
        return super.onContextItemSelected(item);
    }

}