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.abiansoftware.lib.reader.AbianReaderItemActivity.java

@Override
public boolean onOptionsItemSelected(com.actionbarsherlock.view.MenuItem item) {
    if (item.getItemId() == android.R.id.home) {
        Intent intent = new Intent(this, AbianReaderActivity.class);
        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        startActivity(intent);/*ww w.  jav  a 2  s .  c  o m*/

        return true;
    } else if (item.getItemId() == SHARE_ITEM_ID) {
        String shareMessage = getString(R.string.share_message);
        String shareTitle = getString(R.string.share_title);

        AbianReaderItem targetItem = AbianReaderApplication.getData().getItemNumber(m_currentPage);

        Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND);
        sharingIntent.setType("text/plain");
        sharingIntent.putExtra(Intent.EXTRA_SUBJECT, shareMessage);
        sharingIntent.putExtra(Intent.EXTRA_TEXT, targetItem.getLink());
        startActivity(Intent.createChooser(sharingIntent, shareTitle));

        return true;
    } else if (item.getItemId() == OPEN_BROWSER_ITEM_ID) {
        AbianReaderItem targetItem = AbianReaderApplication.getData().getItemNumber(m_currentPage);

        String url = targetItem.getLink();
        Intent i = new Intent(Intent.ACTION_VIEW);
        i.setData(Uri.parse(url));
        startActivity(i);
    }

    return super.onOptionsItemSelected(item);
}

From source file:com.fsa.en.dron.activity.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    RateThisApp.Config config = new RateThisApp.Config(5, 10);
    config.setTitle(R.string.my_own_title);
    config.setMessage(R.string.my_own_message);
    config.setYesButtonText(R.string.my_own_rate);
    config.setNoButtonText(R.string.my_own_thanks);
    config.setCancelButtonText(R.string.my_own_cancel);
    RateThisApp.init(config);//  w w w .  j a  v a  2s. co m
    RateThisApp.setCallback(new RateThisApp.Callback() {
        @Override
        public void onYesClicked() {
            final String appPackageName = getPackageName(); // getPackageName() from Context or Activity  object
            try {
                startActivity(
                        new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + appPackageName)));
            } catch (android.content.ActivityNotFoundException anfe) {
                startActivity(new Intent(Intent.ACTION_VIEW,
                        Uri.parse("http://play.google.com/store/apps/details?id=" + appPackageName)));
            }
        }

        @Override
        public void onNoClicked() {
            TastyToast.makeText(getApplicationContext(), "Vuelve pronto!", TastyToast.LENGTH_LONG,
                    TastyToast.INFO);
        }

        @Override
        public void onCancelClicked() {
            TastyToast.makeText(getApplicationContext(), "Prometo tomar mejores fotografias!",
                    TastyToast.LENGTH_LONG, TastyToast.ERROR);
        }
    });
    button = (Button) findViewById(R.id.button);
    button.setVisibility(View.INVISIBLE);
    button.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            checkConnection();
        }
    });
    BottomNavigationBar bottomNavigationBar = (BottomNavigationBar) findViewById(R.id.bottom_navigation_bar);
    bottomNavigationBar.setBackgroundStyle(BottomNavigationBar.BACKGROUND_STYLE_RIPPLE);
    bottomNavigationBar.setMode(BottomNavigationBar.MODE_FIXED);
    bottomNavigationBar.setBackgroundStyle(BottomNavigationBar.BACKGROUND_STYLE_STATIC);
    bottomNavigationBar.setBarBackgroundColor(R.color.material_light_blue_800);
    bottomNavigationBar.setActiveColor(R.color.material_grey_900);
    bottomNavigationBar.setInActiveColor(R.color.material_blue_grey_200);
    bottomNavigationBar.addItem(new BottomNavigationItem(R.drawable.compose, "Mensaje"))
            .addItem(new BottomNavigationItem(R.drawable.sociales, "Sociales"))
            .addItem(new BottomNavigationItem(R.drawable.share, "Cuntale a un amigo")).initialise();
    bottomNavigationBar.setTabSelectedListener(new BottomNavigationBar.OnTabSelectedListener() {
        @Override
        public void onTabSelected(int position) {
            switch (position) {
            case 0:
                Intent email = new Intent(Intent.ACTION_SEND);
                email.putExtra(Intent.EXTRA_EMAIL, new String[] { "marceloespinoza00@gmail.com" });
                email.putExtra(Intent.EXTRA_SUBJECT, "Formosa en dron");
                email.putExtra(Intent.EXTRA_TEXT, "Dej tu mensaje");
                email.setType("message/rfc822");
                startActivity(Intent.createChooser(email, "Elige un cliente :"));
                break;
            case 1:
                Intent intent = new Intent(getApplication(), FacebookActivity.class);
                startActivity(intent);
                break;
            case 2:

                Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND);
                sharingIntent.setType("text/plain");
                sharingIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Formosa en dron");
                sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT,
                        "https://play.google.com/store/apps/details?id=com.fsa.en.dron");
                startActivity(Intent.createChooser(sharingIntent, "Compartir via"));
                break;

            }

        }

        @Override
        public void onTabUnselected(int position) {

        }

        @Override
        public void onTabReselected(int position) {
            switch (position) {
            case 0:

                break;
            case 1:
                Intent intent = new Intent(getApplication(), FacebookActivity.class);
                startActivity(intent);
                break;
            case 2:

                break;

            }
        }
    });
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    LayoutInflater inflator = LayoutInflater.from(this);
    View v = inflator.inflate(R.layout.toolbar_title, null);
    Typeface budget = Typeface.createFromAsset(getAssets(), "fonts/Budget.otf");
    Typeface typographica = Typeface.createFromAsset(getAssets(), "fonts/TypoGraphica.otf");
    TextView mToolbarCustomTitle = (TextView) v.findViewById(R.id.title);
    TextView mToolbarCustomSubTitle = (TextView) v.findViewById(R.id.subtitle);
    mToolbarCustomTitle.setText("Formosa");
    mToolbarCustomSubTitle.setText("en dron");
    mToolbarCustomTitle.setTypeface(typographica);
    mToolbarCustomSubTitle.setTypeface(budget);
    getSupportActionBar().setCustomView(v);
    getSupportActionBar().setDisplayShowTitleEnabled(false);
    getSupportActionBar().setDisplayShowCustomEnabled(true);
    toolbar.setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener() {
        @Override
        public boolean onMenuItemClick(MenuItem item) {
            int id = item.getItemId();
            if (id == R.id.recargar) {
                checkConnection();
            }
            if (id == R.id.info) {
                showDialog();
            }
            return false;
        }
    });
    recyclerView = (RecyclerView) findViewById(R.id.recycler_view);
    recyclerView.addOnItemTouchListener(new GalleryAdapter.RecyclerTouchListener(getApplicationContext(),
            recyclerView, new GalleryAdapter.ClickListener() {
                @Override
                public void onClick(View view, int position) {
                    Bundle bundle = new Bundle();
                    bundle.putSerializable("images", images);
                    bundle.putInt("position", position);

                    FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
                    SlideshowDialogFragment newFragment = SlideshowDialogFragment.newInstance();
                    newFragment.setArguments(bundle);
                    newFragment.show(ft, "slideshow");
                }

                @Override
                public void onLongClick(View view, int position) {

                }
            }));
    pDialog = new ProgressDialog(this);
    images = new ArrayList<>();
    mAdapter = new GalleryAdapter(getApplicationContext(), images);
    RecyclerView.LayoutManager mLayoutManager = new GridLayoutManager(getApplicationContext(), 2);
    recyclerView.setLayoutManager(mLayoutManager);
    recyclerView.setItemAnimator(new DefaultItemAnimator());
    recyclerView.setAdapter(mAdapter);

}

From source file:com.cairoconfessions.MainActivity.java

public void sendShare(View view) {
    Intent sendIntent = new Intent();
    String shareMessage = ((TextView) ((LinearLayout) view.getParent().getParent())
            .findViewById(R.id.text_main)).getText().toString();
    sendIntent.setAction(Intent.ACTION_SEND);
    shareMessage = "I would like to share this confession with you:\n\"" + shareMessage + '"';
    sendIntent.putExtra(Intent.EXTRA_TEXT, shareMessage);
    sendIntent.setType("text/plain");
    startActivity(sendIntent);/*w ww.  ja v a  2s. c om*/
}

From source file:co.nerdart.ourss.fragment.EntriesListFragment.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case R.id.menu_share_starred: {
        String starredList = "";
        Cursor cursor = mEntriesCursorAdapter.getCursor();
        if (cursor != null && !cursor.isClosed()) {
            int titlePos = cursor.getColumnIndex(EntryColumns.TITLE);
            int linkPos = cursor.getColumnIndex(EntryColumns.LINK);
            if (cursor.moveToFirst()) {
                do {
                    starredList += cursor.getString(titlePos) + "\n" + cursor.getString(linkPos) + "\n\n";
                } while (cursor.moveToNext());
            }/*from ww  w. ja  v a  2s .c o  m*/
            startActivity(Intent.createChooser(
                    new Intent(Intent.ACTION_SEND)
                            .putExtra(Intent.EXTRA_SUBJECT, getString(R.string.share_favorites_title))
                            .putExtra(Intent.EXTRA_TEXT, starredList).setType(Constants.MIMETYPE_TEXT_PLAIN),
                    getString(R.string.menu_share)));
        }
        return true;
    }
    case R.id.menu_refresh: {
        if (!FetcherService.isRefreshingFeeds) {
            getActivity().startService(
                    new Intent(getActivity(), FetcherService.class).setAction(Constants.ACTION_REFRESH_FEEDS));
        }
        return true;
    }
    case R.id.menu_all_read: {
        mEntriesCursorAdapter.markAllAsRead();
        return true;
    }
    case R.id.menu_hide_read: {
        if (!PrefUtils.getBoolean(PrefUtils.SHOW_READ, true)) {
            PrefUtils.putBoolean(PrefUtils.SHOW_READ, true);
            item.setTitle(R.string.context_menu_hide_read).setIcon(R.drawable.hide_reads);
        } else {
            PrefUtils.putBoolean(PrefUtils.SHOW_READ, false);
            item.setTitle(R.string.context_menu_show_read).setIcon(R.drawable.view_reads);
        }
        return true;
    }
    case R.id.menu_settings: {
        startActivity(new Intent(getActivity(), GeneralPrefsActivity.class));
        return true;
    }
    }
    return super.onOptionsItemSelected(item);
}

From source file:com.example.polytech.orientatewatch.ForecastFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    // The ArrayAdapter will take data from a source and
    // use it to populate the ListView it's attached to.
    mForecastAdapter = new ArrayAdapter<String>(getActivity(), // The current context (this activity)
            R.layout.list_item_forecast, // The name of the layout ID.
            R.id.list_item_forecast_textview, // The ID of the textview to populate.
            new ArrayList<String>());
    mForecastAdapterDetails = new ArrayAdapter<String>(getActivity(), // The current context (this activity)
            R.layout.list_item_forecast, // The name of the layout ID.
            R.id.list_item_forecast_textview, // The ID of the textview to populate.
            new ArrayList<String>());

    View rootView = inflater.inflate(R.layout.fragment_main, container, false);

    // Get a reference to the ListView, and attach this adapter to it.
    ListView listView = (ListView) rootView.findViewById(R.id.listview_forecast);

    listView.setAdapter(mForecastAdapter);
    listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        @Override/*from w w  w. j  a  v a2 s . c  o  m*/
        public void onItemClick(AdapterView<?> adapterView, View view, int position, long l) {
            ByteArrayOutputStream stream = new ByteArrayOutputStream();
            bmpIcon.compress(Bitmap.CompressFormat.PNG, 100, stream);
            final byte[] byteArray = stream.toByteArray();
            String forecast = mForecastAdapterDetails.getItem(position);
            Intent intent = new Intent(getActivity(), DetailActivity.class)
                    .putExtra(Intent.EXTRA_TEXT, forecast).putExtra("icon", byteArray);
            startActivity(intent);
        }
    });

    return rootView;
}

From source file:app.com.oz_heng.android.sunshine.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, mForecast + FORECAST_SHARE_HASHTAG);
    return shareIntent;
}

From source file:ca.rmen.android.poetassistant.wotd.Wotd.java

private static PendingIntent getShareIntent(Context context, DictionaryEntry entry) {
    Intent intent = new Intent(Intent.ACTION_SEND);
    intent.putExtra(Intent.EXTRA_TEXT, buildWotdShareContent(context, entry));
    intent.setType("text/plain");
    return PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
}

From source file:com.example.faisal.sunshine.app.ForecastFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    // Create some dummy data for the ListView.  Here's a sample weekly forecast
    final String[] data = { "Mon 6/23- Sunny - 31/17", "Tue 6/24 - Foggy - 21/8",
            "Wed 6/25 - Cloudy - 22/17", "Thurs 6/26 - Rainy - 18/11", "Fri 6/27 - Foggy - 21/10",
            "Sat 6/28 - TRAPPED IN WEATHERSTATION - 23/18", "Sun 6/29 - Sunny - 20/7" };
    final List<String> weekForecast = new ArrayList<String>(Arrays.asList(data));

    // Now that we have some dummy forecast data, create an ArrayAdapter.
    // The ArrayAdapter will take data from a source (like our dummy forecast) and
    // use it to populate the ListView it's attached to.
    mForecastAdapter = new ArrayAdapter<String>(getActivity(), // The current context (this activity)
            R.layout.list_item_forecast, // The name of the layout ID.
            R.id.list_item_forecast_textview, // The ID of the textview to populate.
            weekForecast);/*from w  w w  .  j av  a 2s . co  m*/

    View rootView = inflater.inflate(R.layout.fragment_main, container, false);

    // Get a reference to the ListView, and attach this adapter to it.
    ListView listView = (ListView) rootView.findViewById(R.id.list_view_forecast);
    listView.setAdapter(mForecastAdapter);

    listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            Toast toast = Toast.makeText(getActivity(), mForecastAdapter.getItem(position), Toast.LENGTH_SHORT);
            toast.show();

            Intent detailIntent = new Intent(getActivity(), DetailActivity.class);
            detailIntent.putExtra(Intent.EXTRA_TEXT, mForecastAdapter.getItem(position));
            startActivity(detailIntent);
        }
    });

    return rootView;
}

From source file:com.arquitetaweb.observatorio.MainActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.main, menu);

    // Locate MenuItem with ShareActionProvider
    MenuItem item = menu.findItem(R.id.menu_item_share);
    // Fetch and store ShareActionProvider
    mShareActionProvider = (ShareActionProvider) item.getActionProvider();

    Intent mShareIntent = new Intent();
    mShareIntent.setAction(Intent.ACTION_SEND);
    mShareIntent.putExtra(Intent.EXTRA_TEXT,
            "Fique por dentro do oramento e despesas de Maring acesse o site e baixe o aplicativo.\nhttp://observatoriomga.herokuapp.com/#graph/pie/pai");

    mShareIntent.setType("*/*");

    if (mShareActionProvider != null) {
        mShareActionProvider.setShareIntent(mShareIntent);
    }// w  ww  .  j a  v  a  2 s. c o  m

    return super.onCreateOptionsMenu(menu);
}

From source file:cn.edu.nju.dapenti.activity.EditFeedActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    UiUtils.setPreferenceTheme(this);
    super.onCreate(savedInstanceState);

    ActionBar actionBar = getActionBar();
    actionBar.setDisplayHomeAsUpEnabled(true);

    setContentView(R.layout.activity_feed_edit);
    setResult(RESULT_CANCELED);//ww  w  . j a va2s  .  c om

    Intent intent = getIntent();

    mNameEditText = (EditText) findViewById(R.id.feed_title);
    mUrlEditText = (EditText) findViewById(R.id.feed_url);
    mRetrieveFulltextCb = (CheckBox) findViewById(R.id.retrieve_fulltext);
    mFiltersListView = (ListView) findViewById(android.R.id.list);
    View filtersLayout = findViewById(R.id.filters_layout);
    View buttonLayout = findViewById(R.id.button_layout);

    if (intent.getAction().equals(Intent.ACTION_INSERT) || intent.getAction().equals(Intent.ACTION_SEND)) {
        setTitle(R.string.new_feed_title);

        filtersLayout.setVisibility(View.GONE);

        if (intent.hasExtra(Intent.EXTRA_TEXT)) {
            mUrlEditText.setText(intent.getStringExtra(Intent.EXTRA_TEXT));
        }

        restoreInstanceState(savedInstanceState);
    } else if (intent.getAction().equals(Intent.ACTION_EDIT)) {
        setTitle(R.string.edit_feed_title);

        buttonLayout.setVisibility(View.GONE);

        mFiltersCursorAdapter = new FiltersCursorAdapter(this, null);
        mFiltersListView.setAdapter(mFiltersCursorAdapter);
        mFiltersListView.setOnItemLongClickListener(new OnItemLongClickListener() {
            @Override
            public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
                startActionMode(mFilterActionModeCallback);
                mFiltersCursorAdapter.setSelectedFilter(position);
                mFiltersListView.invalidateViews();
                return true;
            }
        });

        getLoaderManager().initLoader(0, null, this);

        if (!restoreInstanceState(savedInstanceState)) {
            Cursor cursor = getContentResolver().query(intent.getData(), FEED_PROJECTION, null, null, null);

            if (cursor.moveToNext()) {
                mPreviousName = cursor.getString(0);
                mNameEditText.setText(mPreviousName);
                mUrlEditText.setText(cursor.getString(1));
                mRetrieveFulltextCb.setChecked(cursor.getInt(2) == 1);
                cursor.close();
            } else {
                cursor.close();
                Toast.makeText(EditFeedActivity.this, R.string.error, Toast.LENGTH_SHORT).show();
                finish();
            }
        }
    }
}