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.btmura.android.reddit.app.MenuHelper.java

public static void share(Context context, CharSequence subject, CharSequence text) {
    Intent intent = new Intent(Intent.ACTION_SEND);
    intent.setType("text/plain");
    intent.putExtra(Intent.EXTRA_SUBJECT, subject);
    intent.putExtra(Intent.EXTRA_TEXT, text);
    Contexts.startActivity(context, makeChooser(context, intent, R.string.menu_share));
}

From source file:com.app.common.util.IntentUtils.java

public static void startEmailActivity(Context context, String to, String subject, String body) {
    final Intent intent = new Intent(Intent.ACTION_SEND);
    intent.setType("message/rfc822");

    if (!TextUtils.isEmpty(to)) {
        intent.putExtra(Intent.EXTRA_EMAIL, new String[] { to });
    }//from   ww  w.  j  a v  a 2  s . c  om
    if (!TextUtils.isEmpty(subject)) {
        intent.putExtra(Intent.EXTRA_SUBJECT, subject);
    }
    if (!TextUtils.isEmpty(body)) {
        intent.putExtra(Intent.EXTRA_TEXT, body);
    }

    final PackageManager pm = (PackageManager) context.getPackageManager();
    try {
        if (pm.queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY).size() == 0) {
            intent.setType("text/plain");
        }
    } catch (Exception e) {
        Log.w("Exception encountered while looking for email intent receiver.", e);
    }

    context.startActivity(intent);
}

From source file:com.chale22.ico01.ThemeActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    mShareIntent = new Intent();
    mShareIntent.setAction(Intent.ACTION_SEND);
    mShareIntent.setType("text/plain");
    mShareIntent.putExtra(Intent.EXTRA_TEXT, "From me to you, this text is new.");

    tabs = (PagerSlidingTabStrip) findViewById(R.id.tabs);
    ViewPager pager = (ViewPager) findViewById(R.id.pager);

    adapter = new MyPagerAdapter(getSupportFragmentManager());

    pager.setAdapter(adapter);//  ww  w .  ja v a 2 s .  c o m

    final int pageMargin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 4,
            getResources().getDisplayMetrics());
    pager.setPageMargin(pageMargin);

    tabs.setViewPager(pager);

}

From source file:at.jclehner.appopsxposed.BugReportBuilder.java

public static void buildAndSend(final Context context) {
    if (!SU.available()) {
        Toast.makeText(context, R.string.toast_needs_root, Toast.LENGTH_SHORT).show();
        return;// w ww  .  ja v a 2s. c o m
    }

    Toast.makeText(context, R.string.building_toast, Toast.LENGTH_LONG).show();

    final BugReportBuilder brb = new BugReportBuilder(context);

    new AsyncTask<Void, Void, Uri>() {

        @Override
        protected Uri doInBackground(Void... params) {
            return brb.build();
        }

        @Override
        protected void onPostExecute(Uri result) {
            final ArrayList<Parcelable> uris = new ArrayList<Parcelable>();
            uris.add(result);

            final Intent target = new Intent(Intent.ACTION_SEND_MULTIPLE);
            target.setType("text/plain");
            target.putExtra(Intent.EXTRA_SUBJECT,
                    "[REPORT][AppOpsXposed " + Util.getAoxVersion(context) + "] " + Build.FINGERPRINT);
            target.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris);
            //target.putExtra(Intent.EXTRA_STREAM, result);
            target.putExtra(Intent.EXTRA_TEXT, "!!! BUG REPORTS WITHOUT ADDITIONAL INFO WILL BE IGNORED !!!");
            //target.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);

            final Intent intent = Intent.createChooser(target, null);
            //intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);

            context.startActivity(intent);
        }
    }.execute();
}

From source file:com.commonsware.android.sap.MainActivity.java

@Override
public void afterTextChanged(Editable s) {
    shareIntent.putExtra(Intent.EXTRA_TEXT, s.toString());
    share.setShareIntent(shareIntent);
}

From source file:com.manning.androidhacks.hack004.MainActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    addPreferencesFromResource(R.xml.prefs);

    Preference sharePref = findPreference("pref_share");
    Intent shareIntent = new Intent();
    shareIntent.setAction(Intent.ACTION_SEND);
    shareIntent.setType("text/plain");
    shareIntent.putExtra(Intent.EXTRA_SUBJECT, "Check this app!");
    shareIntent.putExtra(Intent.EXTRA_TEXT, "Check this awesome app at: ...");
    sharePref.setIntent(shareIntent);/*from   w ww  . ja  va 2s .  co  m*/

    Preference ratePref = findPreference("pref_rate");
    Uri uri = Uri.parse("market://details?id=" + getPackageName());
    Intent goToMarket = new Intent(Intent.ACTION_VIEW, uri);
    ratePref.setIntent(goToMarket);

    updateUserText();
}

From source file:ca.mudar.snoozy.ui.activity.BaseActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {

    if (item.getItemId() == android.R.id.home) {
        // Respond to the action bar's Up/Home button
        NavUtils.navigateUpFromSameTask(this);
        return true;
    } else if (item.getItemId() == R.id.action_settings) {
        Intent intent = new Intent(this, SettingsActivity.class);
        startActivity(intent);//from   w ww  .  j a va  2 s  .  c o  m
        return true;
    } else if (item.getItemId() == R.id.action_about) {
        Intent intent = new Intent(this, AboutActivity.class);
        startActivity(intent);
        return true;
    } else if (item.getItemId() == R.id.action_eula) {
        Intent intent = new Intent(this, EulaActivity.class);
        startActivity(intent);
        return true;
    } else if (item.getItemId() == R.id.action_share) {
        /*
         Native sharing
          */
        final Bundle extras = new Bundle();
        extras.putString(Intent.EXTRA_SUBJECT, getResources().getString(R.string.share_intent_title));
        extras.putString(Intent.EXTRA_TEXT, Const.URL_PLAYSTORE);

        final Intent sendIntent = new Intent();
        sendIntent.putExtras(extras);
        sendIntent.setAction(Intent.ACTION_SEND);
        sendIntent.setType(this.SEND_INTENT_TYPE);
        startActivity(sendIntent);
    } else if (item.getItemId() == R.id.action_rate) {
        /*
         Launch Playstore to rate app
          */
        final Intent viewIntent = new Intent(Intent.ACTION_VIEW);
        viewIntent.setData(Uri.parse(Const.URL_PLAYSTORE));
        startActivity(viewIntent);
    }

    return super.onOptionsItemSelected(item);
}

From source file:ca.ualberta.slevinsk.gameshow.StatsActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_stats);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);//from  w  w w .  j ava 2  s .  c om

    ViewPager viewPager = (ViewPager) findViewById(R.id.viewpager);
    viewPager.setAdapter(new StatsFragmentPagerAdapter(getSupportFragmentManager(), StatsActivity.this));

    TabLayout tabLayout = (TabLayout) findViewById(R.id.sliding_tabs);
    tabLayout.setupWithViewPager(viewPager);

    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    ReactionTimersManager.initManager(getApplicationContext());
    BuzzerCounterManager.initManager(getApplicationContext());

    FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
    fab.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Intent intent = new Intent(Intent.ACTION_SEND);
            intent.setType("text/rfc822");
            intent.putExtra(Intent.EXTRA_SUBJECT, "slevinsk - stats");
            intent.putExtra(Intent.EXTRA_TEXT,
                    BuzzerCounterController.generateEmailData() + ReactionTimersController.generateEmailData());

            try {
                startActivity(intent);
            } catch (ActivityNotFoundException e) {
                Snackbar.make(view, "There is no email client installed", Snackbar.LENGTH_LONG).show();
            }

        }
    });

}

From source file:com.savvywits.wethepeople.RESTService.java

@Override
protected void onHandleIntent(Intent intent) {
    Bundle extras = intent.getExtras();/*  w w  w .  j  av a2s . c  o  m*/
    ResultReceiver receiver = extras.getParcelable("receiver");
    String data = extras.getString("zipcode");
    String url = ZIP_CODE_BASE + data;

    Bundle bundle = new Bundle();
    receiver.send(STATUS_RUNNING, Bundle.EMPTY);
    try {
        String json = EntityUtils.toString(new DefaultHttpClient().execute(new HttpGet(url)).getEntity());

        if (!validateJSON(json)) {
            receiver.send(STATUS_ERROR, Bundle.EMPTY);
        } else {
            bundle.putString("rest_result", json);
            receiver.send(STATUS_FINISHED, bundle);
        }
    } catch (UnsupportedEncodingException e) {
        e.printStackTrace();
    } catch (ClientProtocolException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    } catch (Exception e) {
        bundle.putString(Intent.EXTRA_TEXT, e.toString());
        receiver.send(STATUS_ERROR, bundle);
    }
}

From source file:com.chale22.ico01.IconActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_icon);
    mShareIntent = new Intent();
    mShareIntent.setAction(Intent.ACTION_SEND);
    mShareIntent.setType("text/plain");
    mShareIntent.putExtra(Intent.EXTRA_TEXT, "From me to you, this text is new.");

    tabs = (PagerSlidingTabStrip) findViewById(R.id.tabs);
    ViewPager pager = (ViewPager) findViewById(R.id.pager);

    adapter = new IconPagerAdapter(getSupportFragmentManager());

    pager.setAdapter(adapter);// w  w w.  j a  v  a2  s.  c o m

    final int pageMargin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 4,
            getResources().getDisplayMetrics());
    pager.setPageMargin(pageMargin);

    tabs.setViewPager(pager);

}