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:MainActivity.java
public void onClickSwitchActivity(View view) { EditText editText = (EditText) findViewById(R.id.editTextData); String text = editText.getText().toString(); Intent intent = new Intent(this, SecondActivity.class); intent.putExtra(Intent.EXTRA_TEXT, text); startActivity(intent);/*from w ww .java 2 s . c o m*/ }
From source file:im.delight.android.baselib.Social.java
/** * Constructs an Intent for sharing/sending plain text and starts Activity chooser for that Intent * * @param context Context reference to start the Activity chooser from * @param windowTitle the string to be used as the window title for the Activity chooser * @param messageText the body text for the message to be shared * @param messageTitle the title/subject for the message to be shared, if supported by the target app */// w w w . j a v a2s. c om public static void shareText(Context context, String windowTitle, String messageText, String messageTitle) { Intent intentInvite = new Intent(Intent.ACTION_SEND); intentInvite.setType(HTTP.PLAIN_TEXT_TYPE); intentInvite.putExtra(Intent.EXTRA_SUBJECT, messageTitle); intentInvite.putExtra(Intent.EXTRA_TEXT, messageText); context.startActivity(Intent.createChooser(intentInvite, windowTitle)); }
From source file:org.deviceconnect.android.client.fragment.TextDialogFragment.java
@Override public View onCreateView(final LayoutInflater inflater, final ViewGroup container, final Bundle savedInstanceState) { mLogger.entering(getClass().getName(), "onCreateView", new Object[] { inflater, container, savedInstanceState }); View view = inflater.inflate(R.layout.fragment_privacypolicy, null); TextView text = (TextView) view.findViewById(android.R.id.text1); InputStream is = null;/*from w ww . ja va 2s.c o m*/ try { ByteArrayOutputStream os = new ByteArrayOutputStream(); is = getActivity().getResources().openRawResource(getArguments().getInt(Intent.EXTRA_TEXT)); byte[] buf = new byte[BUFFER_SIZE]; while (true) { int len = is.read(buf); if (len < 0) { break; } os.write(buf, 0, len); } text.setText(new String(os.toByteArray(), HTTP.UTF_8)); } catch (IOException e) { mLogger.warning(e.toString()); } finally { if (is != null) { try { is.close(); } catch (IOException e) { mLogger.fine(e.toString()); } } } getDialog().setTitle(getArguments().getInt(Intent.EXTRA_TITLE)); mLogger.exiting(getClass().getName(), "onCreateView", view); return view; }
From source file:com.activiti.android.platform.intent.IntentUtils.java
/** * Allow to send a link to other application installed in the device. * * @param fr//from w w w . j a v a 2s. c o m * @param url */ public static void actionShareLink(Fragment fr, String title, String url) { try { Intent i = new Intent(Intent.ACTION_SEND); i.setType("text/plain"); i.putExtra(Intent.EXTRA_SUBJECT, title); i.putExtra(Intent.EXTRA_TEXT, url); fr.startActivity(Intent.createChooser(i, fr.getActivity().getText(R.string.task_action_share_link))); } catch (ActivityNotFoundException e) { } }
From source file:im.delight.android.commons.Social.java
/** * Displays an application chooser and shares the specified plain text and subject line using the selected application * * @param context a context reference// www. ja v a 2 s. com * @param windowTitle the title for the application chooser's window * @param bodyTextToShare the body text to be shared * @param subjectTextToShare the title or subject for the message to be shared, if supported by the target application */ public static void shareText(final Context context, final String windowTitle, final String bodyTextToShare, final String subjectTextToShare) { final Intent intentInvite = new Intent(Intent.ACTION_SEND); intentInvite.setType(HTTP.PLAIN_TEXT_TYPE); intentInvite.putExtra(Intent.EXTRA_SUBJECT, subjectTextToShare); intentInvite.putExtra(Intent.EXTRA_TEXT, bodyTextToShare); context.startActivity(Intent.createChooser(intentInvite, windowTitle)); }
From source file:com.google.android.apps.chrometophone.ShareLinkActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (Intent.ACTION_SEND.equals(getIntent().getAction())) { String text = getIntent().getExtras().getString(Intent.EXTRA_TEXT); Pattern regex = Pattern.compile("http(s)?://.*"); // find the link Matcher matcher = regex.matcher(text); if (matcher.find()) { mPendingAuth = false;/* ww w .j a v a 2s .c o m*/ mPendingLink = matcher.group(); sendLink(); } } }
From source file:net.quranquiz.ui.QQLastScreenActivity.java
private Intent createShareIntent() { Intent shareIntent = new Intent(Intent.ACTION_SEND); shareIntent.setType("text/plain"); //shareIntent.putExtra(Intent.EXTRA_SUBJECT, " ? "); shareIntent.putExtra(Intent.EXTRA_TEXT, conclusionMessage + " http://quranquiz.net"); return shareIntent; }
From source file:com.github.longkai.zhihu.util.Utils.java
/** * ??/* w w w . j a va 2s . co m*/ * @param context * @param subject * @param content * @return intent */ public static Intent share(Context context, String subject, String content) { Intent share = new Intent(Intent.ACTION_SEND); share.setType("text/plain"); share.putExtra(Intent.EXTRA_SUBJECT, subject); share.putExtra(Intent.EXTRA_TEXT, content + context.getString(R.string.share_from)); return share; }
From source file:at.metalab.donarsson.screeninvader.InvadeScreen.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); ConnectivityManager connectivityManager = (ConnectivityManager) getSystemService( Context.CONNECTIVITY_SERVICE); NetworkInfo networkInfo = connectivityManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI); if (networkInfo.isConnected()) { //TODO: Check if we know a ScreenInvader on this network Intent intent = getIntent();/* w w w . ja va2 s . co m*/ String type = intent.getType(); if (type.startsWith("text/")) { String text = intent.getStringExtra(Intent.EXTRA_TEXT); Pattern pattern = Patterns.WEB_URL; Matcher matcher = pattern.matcher(text); while (matcher.find()) { String url = matcher.group(); new PostUrlTask().execute(url); } } //TODO: Add support for other types (file upload) } else { //TODO: Display a prompt to connect to a WiFi Toast.makeText(getApplicationContext(), getString(R.string.no_wifi_toast), Toast.LENGTH_LONG).show(); } finish(); }
From source file:cc.softwarefactory.lokki.android.fragments.AboutFragment.java
private void openTellAFriendActivity() { try {//from w ww . ja va 2 s. co m Intent intent = new Intent(Intent.ACTION_SEND); intent.setType("text/plain"); intent.putExtra(Intent.EXTRA_SUBJECT, getString(R.string.share_subject)); intent.putExtra(Intent.EXTRA_TEXT, getString(R.string.share_text)); startActivity(Intent.createChooser(intent, getString(R.string.share))); } catch (ActivityNotFoundException e) { Log.e(TAG, "Couldn't open 'tell a friend about lokki' activity"); } }