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.Bhailal_Chauhan.retailapp.view.fragment.ContactUsFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.frag_about, container, false);

    getActivity().setTitle("Contact Us");

    mToolbar = (Toolbar) rootView.findViewById(R.id.htab_toolbar);
    if (mToolbar != null) {
        ((ECartHomeActivity) getActivity()).setSupportActionBar(mToolbar);
    }/*ww w .  jav a2  s  .  c  om*/

    if (mToolbar != null) {
        ((ECartHomeActivity) getActivity()).getSupportActionBar().setDisplayHomeAsUpEnabled(true);

        mToolbar.setNavigationIcon(R.drawable.ic_drawer);

    }

    mToolbar.setNavigationOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            ((ECartHomeActivity) getActivity()).getmDrawerLayout().openDrawer(GravityCompat.START);
        }
    });

    mToolbar.setTitleTextColor(Color.WHITE);

    rootView.findViewById(R.id.locations).setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {

        }
    });

    rootView.findViewById(R.id.contact_num).setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {

            Intent callIntent = new Intent(Intent.ACTION_DIAL);
            callIntent.setData(Uri.parse("tel:" + "8347337366"));
            startActivity(callIntent);

        }
    });

    rootView.setFocusableInTouchMode(true);
    rootView.requestFocus();
    rootView.setOnKeyListener(new View.OnKeyListener() {

        @Override
        public boolean onKey(View v, int keyCode, KeyEvent event) {

            if (event.getAction() == KeyEvent.ACTION_UP && keyCode == KeyEvent.KEYCODE_BACK) {

                Utils.switchContent(R.id.frag_container, Utils.HOME_FRAGMENT,
                        ((ECartHomeActivity) (getContext())), AnimationType.SLIDE_UP);

            }
            return true;
        }
    });

    rootView.findViewById(R.id.site_dev).setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://bhailalchauhan.com/"));
            startActivity(browserIntent);

        }
    });

    rootView.findViewById(R.id.email).setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {

            final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
            emailIntent.setType("text/plain");
            emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[] { "hibhailal458@gmail.com" });
            emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Hello There");
            emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, "Add Message here");

            emailIntent.setType("message/rfc822");

            try {
                startActivity(Intent.createChooser(emailIntent, "Send email using..."));
            } catch (android.content.ActivityNotFoundException ex) {
                Toast.makeText(getActivity(), "No email clients installed.", Toast.LENGTH_SHORT).show();
            }

        }
    });

    return rootView;
}

From source file:atv.com.project.monkeylivetv.Activity.MainActivity.java

private Intent createShareIntent() {
    Intent shareIntent = new Intent(Intent.ACTION_SEND);
    shareIntent.setType("text/plain");
    shareIntent.putExtra(Intent.EXTRA_TEXT, "http://monkeylivetv.com");
    return shareIntent;
}

From source file:org.exoplatform.shareextension.ShareActivity.java

@Override
protected void onCreate(Bundle bundle) {
    super.onCreate(bundle);

    setContentView(R.layout.share_extension_activity);

    loadingIndicator = (ProgressBar) findViewById(R.id.share_progress_indicator);
    mainButton = (Button) findViewById(R.id.share_button);
    mainButton.setTag(R.attr.share_button_type_post);
    online = false;// www .  j  a  v  a2 s.  co  m
    postInfo = new SocialPostInfo();

    if (isIntentCorrect()) {
        Intent intent = getIntent();
        String type = intent.getType();
        if ("text/plain".equals(type)) {
            // The share does not contain an attachment
            // TODO extract the link info - MOB-1866
            postInfo.postMessage = intent.getStringExtra(Intent.EXTRA_TEXT);
        } else {
            // The share contains an attachment
            if (mMultiFlag) {
                mAttachmentUris = intent.getParcelableArrayListExtra(Intent.EXTRA_STREAM);
            } else {
                Uri contentUri = (Uri) intent.getParcelableExtra(Intent.EXTRA_STREAM);
                if (contentUri != null) {
                    mAttachmentUris = new ArrayList<Uri>();
                    mAttachmentUris.add(contentUri);
                }
                if (Log.LOGD) {
                    Log.d(LOG_TAG, "Number of files to share: ", mAttachmentUris.size());
                }
            }
            prepareAttachmentsAsync();
        }

        init();

        // Create and display the composer, aka ComposeFragment
        ComposeFragment composer = ComposeFragment.getFragment();
        openFragment(composer, ComposeFragment.COMPOSE_FRAGMENT, Anim.NO_ANIM);
    } else {
        // We're not supposed to reach this activity by anything else than an
        // ACTION_SEND intent
        finish();
    }

}

From source file:com.comrella.webcomics.navigation.MainActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // Handle action bar item clicks here. The action bar will
    // automatically handle clicks on the Home/Up button, so long
    // as you specify a parent activity in AndroidManifest.xml.
    int id = item.getItemId();
    if (id == R.id.action_settings) {
        Intent sendIntent = new Intent();
        sendIntent.setAction(Intent.ACTION_SEND);
        sendIntent.putExtra(Intent.EXTRA_TEXT,
                "Get Cheesy Funny Comic Strips on your Android Device. Find us on Play Store! www.comrella.com");
        sendIntent.setType("text/plain");
        startActivity(Intent.createChooser(sendIntent, getResources().getText(R.string.share_app_title)));
    }/*  w  w  w  . ja  va 2s .  c o m*/
    return super.onOptionsItemSelected(item);
}

From source file:de.appplant.cordova.plugin.emailcomposer.EmailComposer.java

/**
 * Setzt den Body der Mail.//www  .j ava  2 s  .  c  om
 */
private void setBody(String body, Boolean isHTML, Intent draft) {
    if (isHTML) {
        draft.putExtra(android.content.Intent.EXTRA_TEXT, Html.fromHtml(body));
        draft.setType("text/html");
    } else {
        draft.putExtra(android.content.Intent.EXTRA_TEXT, body);
        draft.setType("text/plain");
    }
}

From source file:com.elkriefy.android.apps.chubbytabby.activity.MainActivity.java

private PendingIntent createPendingShareIntent() {
    Intent actionIntent = new Intent(Intent.ACTION_SEND);
    actionIntent.setType("text/html");
    actionIntent.putExtra(Intent.EXTRA_TEXT, "This is the Chubby Bunny Challenge/n" + URL);
    return PendingIntent.getActivity(getApplicationContext(), 0, actionIntent, 0);
}

From source file:com.example.weewilfred.sunshine.ForecastFragment.java

@Override //This "onCreateView" method is where the UI gets initialized
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    /*String[] data = {/*ww w .  j  av  a  2  s.  com*/
        "Monday - Sunny - 14/24",
        "Tuesday - Cloudy - 10/19",
        "Wednesday - Solar Flares - -45/134",
        "Thursday - Everyone is Dead - ?",
        "Friday - Everyone gone - gone.. gone",
        "Saturday - Glowing Green - 22/24",
        "Sunday - Excellent weather for Zombies"
    }; DUMMY DATA
            
    List<String> weekForecast = new ArrayList<String>(Arrays.asList(data));   DUMMY DATA*/

    // Get a reference to the ListView, and attach this adapter to it.
    mForecastAdapter = new ArrayAdapter<String>(
            //The current context (This fragments parent activity)
            getActivity(),
            //ID of list item layout style
            R.layout.list_item_forecast,
            //ID of the textview to populate the layout
            R.id.list_item_forecast_textview,
            // Pass in Forecast Data To populate the text
            new ArrayList<String>());

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

    //Set the mForecast Adapter to send its adapted info to the listview
    ListView listView = (ListView) rootView.findViewById(R.id.listview_forecast);
    listView.setAdapter(mForecastAdapter);
    listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> adapterView, View view, int position, long l) {
            String forecast = mForecastAdapter.getItem(position);
            //Toast.makeText(getActivity(), forecast, Toast.LENGTH_SHORT).show();
            Intent DetailIntent = new Intent(getActivity(), DetailActivity.class).putExtra(Intent.EXTRA_TEXT,
                    forecast);
            startActivity(DetailIntent);
        }
    });

    return rootView;
}

From source file:io.github.protino.codewatch.ui.ProfileActivity.java

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_profile);
    ButterKnife.bind(this);

    userId = getIntent().getStringExtra(Intent.EXTRA_TEXT);

    if (userId == null) {
        throw new IllegalArgumentException("User-id not passed");
    }/*from   www. j a  va2 s .c o m*/

    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setTitle("");
    userId = getIntent().getStringExtra(Intent.EXTRA_TEXT);
    collapsingToolbarLayout.setTitle("");
    collapsingToolbarLayout.setExpandedTitleColor(Color.TRANSPARENT);
    collapsingToolbarLayout.setCollapsedTitleTextColor(Color.WHITE);

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

    initializeData();

    achievementsAdapter = new AchievementsAdapter(this, badgeItemList);
    languageAdapter = new LanguageAdapter(this, languageList);

    //setup recycler views and adapters
    languageListView.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false));
    languageListView.setAdapter(languageAdapter);

    achievementsListView.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false));
    achievementsListView.setAdapter(achievementsAdapter);

    String firebaseUserId = CacheUtils.getFirebaseUserId(this);
    FirebaseDatabase firebaseDatabase = FirebaseDatabase.getInstance();
    achievementDatabaseRef = firebaseDatabase.getReference().child("achv").child(firebaseUserId).child(userId);
}

From source file:edu.mit.mobile.android.demomode.Preferences.java

private void shareConfig() {
    startActivity(Intent.createChooser(//from w  w w. jav a2s . c om
            new Intent(Intent.ACTION_SEND).setType("text/plain").putExtra(Intent.EXTRA_TEXT, toConfigString())
                    .putExtra(Intent.EXTRA_SUBJECT, getText(R.string.app_name) + " Config"),
            getText(R.string.share_config)));
}

From source file:com.anysoftkeyboard.ui.SendBugReportUiActivity.java

public void onSendCrashReport(View v) {
    String[] recipients = new String[] { BuildConfig.CRASH_REPORT_EMAIL_ADDRESS };

    Intent sendMail = new Intent();
    sendMail.setAction(Intent.ACTION_SEND);
    sendMail.setType("plain/text");
    sendMail.putExtra(Intent.EXTRA_EMAIL, recipients);
    sendMail.putExtra(Intent.EXTRA_SUBJECT, getText(R.string.ime_crashed_title));
    sendMail.putExtra(Intent.EXTRA_TEXT, mCrashReportDetails.crashReportText);

    try {/*from   w  w  w. java 2  s  .c om*/
        Intent sender = Intent.createChooser(sendMail, getString(R.string.ime_crashed_intent_selector_title));
        sender.putExtra(Intent.EXTRA_EMAIL, sendMail.getStringArrayExtra(Intent.EXTRA_EMAIL));
        sender.putExtra(Intent.EXTRA_SUBJECT, sendMail.getStringExtra(Intent.EXTRA_SUBJECT));
        sender.putExtra(Intent.EXTRA_TEXT, mCrashReportDetails.crashReportText);

        Log.i(TAG, "Will send crash report using " + sender);
        startActivity(sender);
    } catch (android.content.ActivityNotFoundException ex) {
        Toast.makeText(getApplicationContext(), "Unable to send bug report via e-mail!", Toast.LENGTH_LONG)
                .show();
    }

    finish();
}