List of usage examples for android.content Intent EXTRA_TEXT
String EXTRA_TEXT
To view the source code for android.content Intent EXTRA_TEXT.
Click Source Link
From source file:at.bitfire.davdroid.ui.DebugInfoActivity.java
public void onShare(MenuItem item) { if (!TextUtils.isEmpty(report)) { Intent sendIntent = new Intent(); sendIntent.setAction(Intent.ACTION_SEND); sendIntent.setType("text/plain"); sendIntent.putExtra(Intent.EXTRA_SUBJECT, getString(R.string.app_name) + " " + BuildConfig.VERSION_NAME + " debug info"); // since Android 4.1, FileProvider permissions are handled in a useful way (using ClipData) boolean asAttachment = Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN; if (asAttachment) try { File debugInfoDir = new File(getCacheDir(), "debug-info"); debugInfoDir.mkdir();/*from w ww . j a v a 2 s . c om*/ reportFile = new File(debugInfoDir, "debug.txt"); App.log.fine("Writing debug info to " + reportFile.getAbsolutePath()); FileWriter writer = new FileWriter(reportFile); writer.write(report); writer.close(); sendIntent.putExtra(Intent.EXTRA_STREAM, FileProvider.getUriForFile(this, getString(R.string.authority_log_provider), reportFile)); sendIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); } catch (IOException e) { // creating an attachment failed, so send it inline asAttachment = false; StringBuilder builder = new StringBuilder(); builder.append("Couldn't write debug info file:\n").append(ExceptionUtils.getStackTrace(e)) .append("\n\n").append(report); report = builder.toString(); } if (!asAttachment) sendIntent.putExtra(Intent.EXTRA_TEXT, report); startActivity(Intent.createChooser(sendIntent, null)); } }
From source file:com.example.android.sunshine.fragments.ForecastFragment.java
@Override public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { // 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. // The current context (this activity) // The name of the layout ID. // The ID of the textview to populate. mForecastAdapter = new ArrayAdapter<>(getActivity(), // The current context (this activity) R.layout.list_item_forecast, // The name of the layout ID. R.id.tvListItemForecast, // The ID of the textview to populate. new ArrayList<String>()); // Get a referece to the ListView and attach the adapter to it. ListView listView = (ListView) view.findViewById(R.id.listView_forecast); listView.setAdapter(mForecastAdapter); listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override// ww w .j a v a 2 s .c om public void onItemClick(AdapterView<?> parent, View view, int position, long id) { String forecast = mForecastAdapter.getItem(position); Intent intent = new Intent(getActivity(), DetailActivity.class); intent.putExtra(Intent.EXTRA_TEXT, forecast); startActivity(intent); } }); }
From source file:com.thathwam.sunshine.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 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" }; 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 ww .j a v a 2 s. c o m View rootView = inflater.inflate(R.layout.fragment_main, container, false); // Get a reference to the ListView, and attach this adapter to it. final ListView listView = (ListView) rootView.findViewById(R.id.listview_forecast); listView.setAdapter(mForecastAdapter); listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { String forecast = mForecastAdapter.getItem(position); Intent intent = new Intent(getActivity(), DetailActivity.class).putExtra(Intent.EXTRA_TEXT, forecast); startActivity(intent); } }); return rootView; }
From source file:com.example.abrahamrequena.sunshine.ForecastFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // 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. 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 .java2 s . c o m*/ public void onItemClick(AdapterView<?> parent, View view, int position, long id) { CharSequence forecast = mForecastAdapter.getItem(position); Intent intent = new Intent(getActivity(), DetailActivity.class).putExtra(Intent.EXTRA_TEXT, forecast); startActivity(intent); } }); return rootView; }
From source file:com.sayo.android.sunshine.ForecastFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // 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_forcast, // 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// w w w . java 2 s . c o m public void onItemClick(AdapterView<?> parent, View view, int position, long id) { String forecast = (String) parent.getItemAtPosition(position); Intent otherIntent = new Intent(getActivity(), DetailActivity.class).putExtra(Intent.EXTRA_TEXT, forecast); startActivity(otherIntent); } }); return rootView; }
From source file:ayushi.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); }/*w w w .j a v a 2 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:" + "8888813275")); 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://hiteshsahu.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[] { "hiteshkumarsahu1990@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:org.peterbaldwin.client.android.tinyurl.SendTinyUrlActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setTitle(R.string.title_creating);/* www.j ava 2 s. c o m*/ setContentView(R.layout.send); mTextOriginalUrl = (TextView) findViewById(R.id.text_original_url); mProgressUrl = (ProgressBar) findViewById(R.id.progress_url); mTextUrl = (TextView) findViewById(R.id.text_url); mButtonSend = (Button) findViewById(R.id.button_send); mButtonCopy = (Button) findViewById(R.id.button_copy); mButtonCancel = (Button) findViewById(R.id.button_cancel); mButtonSend.setOnClickListener(this); mButtonCopy.setOnClickListener(this); mButtonCancel.setOnClickListener(this); // Disable these buttons until the TinyURL has been created. mButtonSend.setEnabled(false); mButtonCopy.setEnabled(false); Intent intent = getIntent(); mUrl = intent.getStringExtra(Intent.EXTRA_TEXT); if (mUrl == null) { // Use a default URL if the activity is launched directly. mUrl = "http://www.google.com/"; } mTextOriginalUrl.setText(mUrl); // Request a TinyURL on a background thread. // This request is fast, so don't worry about the activity being // re-created if the keyboard is opened. new Thread(this).start(); }
From source file:com.bangalore.barcamp.activity.ShareActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.share_screen); mDrawerToggle = BCBFragmentUtils.setupActionBar(this, "Share"); // BCBUtils.createActionBarOnActivity(this); // BCBUtils.addNavigationActions(this); ((EditText) findViewById(R.id.editText1)).addTextChangedListener(new TextWatcher() { @Override// w w w. j a v a2s .com public void onTextChanged(CharSequence s, int start, int before, int count) { } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void afterTextChanged(Editable s) { ((TextView) findViewById(R.id.charsLeftTextView)).setText("Chars left: " + (140 - s.length() - 7)); } }); if (getIntent().hasExtra(SHARE_STRING)) { ((EditText) findViewById(R.id.editText1)).setText(getIntent().getStringExtra(SHARE_STRING)); } Intent intent = new Intent(Intent.ACTION_SEND); intent.setType("text/plain"); final PackageManager pm = getPackageManager(); final Spinner spinner = (Spinner) findViewById(R.id.shareTypeSpinner); ArrayAdapter<CharSequence> adapter = new ArrayAdapter<CharSequence>(this, android.R.layout.simple_spinner_item); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); final List<ResolveInfo> matches = pm.queryIntentActivities(intent, 0); String selectedItem = BCBSharedPrefUtils.getShareSettings(getApplicationContext()); int selectedPos = -1; for (ResolveInfo info : matches) { adapter.add(info.loadLabel(pm)); if (selectedItem.equals(info.loadLabel(pm))) { selectedPos = matches.indexOf(info); } } spinner.setAdapter(adapter); if (selectedPos != -1) { spinner.setSelected(true); spinner.setSelection(selectedPos); } ((TextView) findViewById(R.id.charsLeftTextView)).setText("Chars left: 140"); ((Button) findViewById(R.id.button1)).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(Intent.ACTION_SEND); intent.setType("text/plain"); int appSelectedPos = spinner.getSelectedItemPosition(); ResolveInfo info = matches.get(appSelectedPos); intent.setClassName(info.activityInfo.packageName, info.activityInfo.name); BCBSharedPrefUtils.setShareSettings(getApplicationContext(), (String) info.loadLabel(pm)); intent.putExtra(Intent.EXTRA_TEXT, ((EditText) findViewById(R.id.editText1)).getText().toString() + " #barcampblr"); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent); finish(); } }); BCBFragmentUtils.addNavigationActions(this); supportInvalidateOptionsMenu(); Tracker t = ((BarcampBangalore) getApplication()).getTracker(); // Set screen name. t.setScreenName(this.getClass().getName()); // Send a screen view. t.send(new HitBuilders.AppViewBuilder().build()); }
From source file:com.davila.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 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" }; 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);/*ww w. jav a2s . c o 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.listview_forecast); listView.setAdapter(mForecastAdapter); listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { String forecast = mForecastAdapter.getItem(position); Intent intent = new Intent(getActivity(), DetailActivity.class).putExtra(Intent.EXTRA_TEXT, forecast); startActivity(intent); //Toast.makeText(getActivity(), forecast, Toast.LENGTH_SHORT).show(); } }); return rootView; }
From source file:codepath.watsiapp.utils.Util.java
public static void startShareIntent(Activity activity, ShareableItem patient) { Intent shareIntent = new Intent(); shareIntent.setAction(Intent.ACTION_SEND); shareIntent.putExtra(Intent.EXTRA_TEXT, patient.getShareableUrl()); shareIntent.setType("text/plain"); shareIntent.putExtra(Intent.EXTRA_SUBJECT, "Fund Treatment"); activity.startActivity(Intent.createChooser(shareIntent, "Share Story")); }