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:app.com.example.android.sunshine_tutorial.ForecastFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { List<String> weekForecast = new ArrayList<String>(); mForecastAdapter = new ArrayAdapter<String>(getActivity(), R.layout.list_item_forecast, R.id.list_item_forecast_textview, weekForecast); View rootView = inflater.inflate(R.layout.fragment_main, container, false); ListView listView = (ListView) rootView.findViewById(R.id.listview_forecast); listView.setAdapter(mForecastAdapter); listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override//w ww .ja v a 2s. c o m public void onItemClick(AdapterView<?> parent, View view, int position, long id) { String forecast = mForecastAdapter.getItem(position); Intent goToDetails = new Intent(getActivity(), DetailActivity.class); goToDetails.putExtra(Intent.EXTRA_TEXT, forecast); startActivity(goToDetails); } }); return rootView; }
From source file:org.mrquiz.android.tinyurl.SendTinyUrlActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Intent intent = getIntent();//from ww w . j a v a 2s.c o m mUrl = intent.getStringExtra(Intent.EXTRA_TEXT); if (mUrl == null) { // Use a default URL if the activity is launched directly. mUrl = "http://www.google.com/"; } //moveTaskToBack(true); // Request a TinyShare 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:jahirfiquitiva.iconshowcase.services.MuzeiArtSourceService.java
@Override public void onCustomCommand(int id) { super.onCustomCommand(id); if (id == COMMAND_ID_SHARE) { Artwork currentArtwork = getCurrentArtwork(); Intent shareWall = new Intent(Intent.ACTION_SEND); shareWall.setType("text/plain"); String wallName = currentArtwork.getTitle(); String authorName = currentArtwork.getByline(); String storeUrl = MARKET_URL + getPackageName(); String iconPackName = getString(R.string.app_name); shareWall.putExtra(Intent.EXTRA_TEXT, getString(R.string.share_text, wallName, authorName, iconPackName, storeUrl)); shareWall = Intent.createChooser(shareWall, getString(R.string.share_title)); shareWall.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(shareWall);//from w w w . j a va2 s . c o m } }
From source file:id.zelory.tanipedia.activity.BacaActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_baca); tmp = getIntent().getParcelableExtra("berita"); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar);//w w w . ja v a 2 s .c o m getSupportActionBar().setDisplayHomeAsUpEnabled(true); CollapsingToolbarLayout collapsingToolbar = (CollapsingToolbarLayout) findViewById(R.id.collapsing_toolbar); collapsingToolbar.setTitle("TaniPedia"); animation = AnimationUtils.loadAnimation(this, R.anim.simple_grow); gambar = (ImageView) findViewById(R.id.gambar); judul = (TextView) findViewById(R.id.judul); tanggal = (TextView) findViewById(R.id.tanggal); isi = (DocumentView) findViewById(R.id.isi); root = (LinearLayout) findViewById(R.id.ll_root_berita); fabButton = (FabButton) findViewById(R.id.determinate); fabButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(Intent.ACTION_SEND); intent.setType("text/plain"); intent.putExtra(Intent.EXTRA_SUBJECT, berita.getJudul()); intent.putExtra(Intent.EXTRA_TEXT, berita.getJudul() + "\n" + berita.getAlamat()); startActivity(Intent.createChooser(intent, "Bagikan")); } }); generateBeritaLainnya(); new DownloadData().execute(); }
From source file:de.grobox.blitzmail.SendActivity.java
protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // before doing anything show notification about sending process mNotifyManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); mBuilder = new NotificationCompat.Builder(this); mBuilder.setContentTitle(getString(R.string.sending_mail)).setContentText(getString(R.string.please_wait)) .setSmallIcon(R.drawable.notification_icon).setOngoing(true); // Sets an activity indicator for an operation of indeterminate length mBuilder.setProgress(0, 0, true);//from w ww .j ava 2 s .c o m // Create Pending Intent notifyIntent = new Intent(this, NotificationHandlerActivity.class); notifyIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, notifyIntent, PendingIntent.FLAG_UPDATE_CURRENT); mBuilder.setContentIntent(pendingIntent); // Issues the notification mNotifyManager.notify(0, mBuilder.build()); Properties prefs; try { prefs = getPrefs(); } catch (Exception e) { String msg = e.getMessage(); Log.i("SendActivity", "ERROR: " + msg, e); if (e.getClass().getCanonicalName().equals("java.lang.RuntimeException") && e.getCause() != null && e.getCause().getClass().getCanonicalName().equals("javax.crypto.BadPaddingException")) { msg = getString(R.string.error_decrypt); } showError(msg); return; } // get and handle Intent Intent intent = getIntent(); String action = intent.getAction(); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); if (action.equals(Intent.ACTION_SEND)) { String text = intent.getStringExtra(Intent.EXTRA_TEXT); //String email = intent.getStringExtra(Intent.EXTRA_EMAIL); String subject = intent.getStringExtra(Intent.EXTRA_SUBJECT); String cc = intent.getStringExtra(Intent.EXTRA_CC); String bcc = intent.getStringExtra(Intent.EXTRA_BCC); // Check for empty content if (subject == null && text != null) { // cut all characters from subject after the 128th subject = text.substring(0, (text.length() < 128) ? text.length() : 128); // remove line breaks from subject subject = subject.replace("\n", " ").replace("\r", " "); } else if (subject != null && text == null) { text = subject; } else if (subject == null && text == null) { Log.e("Instant Mail", "Did not send mail, because subject and body empty."); showError(getString(R.string.error_no_body_no_subject)); return; } // create JSON object with mail information mMail = new JSONObject(); try { mMail.put("id", String.valueOf(new Date().getTime())); mMail.put("body", text); mMail.put("subject", subject); mMail.put("cc", cc); mMail.put("bcc", bcc); } catch (JSONException e) { e.printStackTrace(); } // remember mail for later MailStorage.saveMail(this, mMail); // pass mail on to notification dialog class notifyIntent.putExtra("mail", mMail.toString()); // Start Mail Task AsyncMailTask mail = new AsyncMailTask(this, prefs, mMail); mail.execute(); } else if (action.equals("BlitzMailReSend")) { try { mMail = new JSONObject(intent.getStringExtra("mail")); } catch (JSONException e) { e.printStackTrace(); } // pass mail on to notification dialog class notifyIntent.putExtra("mail", mMail.toString()); // Start Mail Task AsyncMailTask mail = new AsyncMailTask(this, prefs, mMail); mail.execute(); } finish(); }
From source file:com.ideateam.plugin.Emailer.java
private void SendEmail(String email, String subject, String text, String attachFile) { String attachPath = Environment.getExternalStorageDirectory().getAbsolutePath() + "/UAR2015/" + attachFile; File file = new File(attachPath); Intent intent = new Intent(Intent.ACTION_SEND); intent.setType("text/plain"); intent.putExtra(Intent.EXTRA_EMAIL, new String[] { email }); intent.putExtra(Intent.EXTRA_SUBJECT, subject); intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(file)); intent.putExtra(Intent.EXTRA_TEXT, Html.fromHtml(text)); this.cordova.getActivity().startActivity(Intent.createChooser(intent, "Send email...")); }
From source file:org.lol.reddit.activities.PostSubmitActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { PrefsUtility.applyTheme(this); super.onCreate(savedInstanceState); final LinearLayout layout = (LinearLayout) getLayoutInflater().inflate(R.layout.post_submit); typeSpinner = (Spinner) layout.findViewById(R.id.post_submit_type); usernameSpinner = (Spinner) layout.findViewById(R.id.post_submit_username); subredditEdit = (EditText) layout.findViewById(R.id.post_submit_subreddit); titleEdit = (EditText) layout.findViewById(R.id.post_submit_title); textEdit = (EditText) layout.findViewById(R.id.post_submit_body); final Intent intent = getIntent(); if (intent != null) { if (intent.hasExtra("subreddit")) { final String subreddit = intent.getStringExtra("subreddit"); if (subreddit != null && subreddit.length() > 0 && !subreddit.matches("/?(r/)?all/?") && subreddit.matches("/?(r/)?\\w+/?")) { subredditEdit.setText(subreddit); }//w w w . j a va2s.c o m } else if (Intent.ACTION_SEND.equalsIgnoreCase(intent.getAction()) && intent.hasExtra(Intent.EXTRA_TEXT)) { final String url = intent.getStringExtra(Intent.EXTRA_TEXT); textEdit.setText(url); } } else if (savedInstanceState != null && savedInstanceState.containsKey("post_title")) { titleEdit.setText(savedInstanceState.getString("post_title")); textEdit.setText(savedInstanceState.getString("post_body")); subredditEdit.setText(savedInstanceState.getString("subreddit")); typeSpinner.setSelection(savedInstanceState.getInt("post_type")); } final ArrayList<RedditAccount> accounts = RedditAccountManager.getInstance(this).getAccounts(); final ArrayList<String> usernames = new ArrayList<String>(); for (RedditAccount account : accounts) { if (!account.isAnonymous()) { usernames.add(account.username); } } if (usernames.size() == 0) { General.quickToast(this, R.string.error_toast_notloggedin); finish(); } usernameSpinner.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, usernames)); typeSpinner.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, postTypes)); // TODO remove the duplicate code here setHint(); typeSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { setHint(); } public void onNothingSelected(AdapterView<?> parent) { } }); final ScrollView sv = new ScrollView(this); sv.addView(layout); setContentView(sv); }
From source file:com.bordengrammar.bordengrammarapp.ParentsFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View root = inflater.inflate(R.layout.fragment_parents, container, false); mail = (LinearLayout) root.findViewById(R.id.linmail); call = (LinearLayout) root.findViewById(R.id.lincall); call.setOnClickListener(new View.OnClickListener() { @Override// w w w . ja v a 2 s. co m public void onClick(View arg0) { Intent cally = new Intent(Intent.ACTION_CALL); cally.setData(Uri.parse("tel:01795424192")); startActivity(cally); } }); mail.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View arg0) { AlertDialog.Builder alert = new AlertDialog.Builder(getActivity()); alert.setTitle("Send a email to Borden Grammar"); alert.setMessage("Message: "); final EditText input = new EditText(getActivity()); alert.setView(input); alert.setPositiveButton("Send", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { String value = input.getText().toString(); // Do something with value! Intent email = new Intent(Intent.ACTION_SEND); email.setType("plain/text"); email.putExtra(android.content.Intent.EXTRA_EMAIL, new String[] { "school@bordengrammar.kent.sch.uk" }); email.putExtra(Intent.EXTRA_SUBJECT, "Email (Sent From BGS APP) "); email.putExtra(Intent.EXTRA_TEXT, value); startActivity(Intent.createChooser(email, "Choose an Email client :")); } }); alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { // Canceled. } }); alert.show(); } }); URL url = null; try { url = new URL( "http://website.bordengrammar.kent.sch.uk/index.php?option=com_rubberdoc&view=category&id=63%3Aletters&Itemid=241&format=feed&type=rss"); } catch (MalformedURLException e) { e.printStackTrace(); } Feed feed = null; try { feed = FeedParser.parse(url); } catch (FeedIOException e) { e.printStackTrace(); } catch (FeedXMLParseException e) { e.printStackTrace(); } catch (UnsupportedFeedException e) { e.printStackTrace(); } Boolean nully = false; for (int i = 0; i < 3; i++) { try { FeedItem item = feed.getItem(i); } catch (NullPointerException e) { e.printStackTrace(); nully = true; Toast.makeText(getActivity().getApplicationContext(), "Some features of this app require a internet connection", Toast.LENGTH_LONG).show(); } } if (!nully) { final FeedItem post1 = feed.getItem(1); final FeedItem post2 = feed.getItem(2); final FeedItem post3 = feed.getItem(3); TextView title1 = (TextView) root.findViewById(R.id.title1); TextView title2 = (TextView) root.findViewById(R.id.title2); TextView title3 = (TextView) root.findViewById(R.id.title3); title1.setText(post1.getTitle()); title2.setText(post2.getTitle()); title3.setText(post3.getTitle()); TextView link1 = (TextView) root.findViewById(R.id.link1); TextView link2 = (TextView) root.findViewById(R.id.link2); TextView link3 = (TextView) root.findViewById(R.id.link3); link1.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { String url1 = post1.getLink().toString(); Intent intent = new Intent(Intent.ACTION_VIEW); intent.setDataAndType(Uri.parse(url1), "text/html"); startActivity(intent); } }); link2.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { String url1 = post2.getLink().toString(); Intent intent = new Intent(Intent.ACTION_VIEW); intent.setDataAndType(Uri.parse(url1), "text/html"); startActivity(intent); } }); link3.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { String url1 = post3.getLink().toString(); Intent intent = new Intent(Intent.ACTION_VIEW); intent.setDataAndType(Uri.parse(url1), "text/html"); startActivity(intent); } }); } else { TextView title1 = (TextView) root.findViewById(R.id.title1); TextView title2 = (TextView) root.findViewById(R.id.title2); TextView title3 = (TextView) root.findViewById(R.id.title3); title1.setText("No connection"); title2.setText("No connection"); title3.setText("No connection"); } TextView reader = (TextView) root.findViewById(R.id.reader); reader.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { final String appPackageName = "com.adobe.reader"; // 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))); } } }); return root; }
From source file:ca.rmen.android.poetassistant.main.PagerAdapter.java
PagerAdapter(Context context, FragmentManager fm, Intent intent) { super(fm);/* w w w . j a va 2 s.c o m*/ Log.v(TAG, "Constructor: intent = " + intent); mContext = context; Uri initialQuery = intent.getData(); // Deep link to query in a specific tab if (initialQuery != null) { Tab tab = Tab.parse(initialQuery.getHost()); if (tab == Tab.PATTERN) { mInitialPatternQuery = initialQuery.getLastPathSegment(); } else if (tab == Tab.RHYMER) { mInitialRhymeQuery = initialQuery.getLastPathSegment(); } else if (tab == Tab.THESAURUS) { mInitialThesaurusQuery = initialQuery.getLastPathSegment(); } else if (tab == Tab.DICTIONARY) { mInitialDictionaryQuery = initialQuery.getLastPathSegment(); } else if (Constants.DEEP_LINK_QUERY.equals(initialQuery.getHost())) { mInitialRhymeQuery = initialQuery.getLastPathSegment(); mInitialThesaurusQuery = initialQuery.getLastPathSegment(); mInitialDictionaryQuery = initialQuery.getLastPathSegment(); } } // Text shared from another app: else if (Intent.ACTION_SEND.equals(intent.getAction())) { mInitialPoemText = intent.getStringExtra(Intent.EXTRA_TEXT); } }
From source file:com.sonetel.plugins.sonetelcallthru.CallThru.java
@Override public void onReceive(final Context context, Intent intent) { if (SipManager.ACTION_GET_PHONE_HANDLERS.equals(intent.getAction())) { // Retrieve and cache infos from the phone app if (!sPhoneAppInfoLoaded) { Resources r = context.getResources(); BitmapDrawable drawable = (BitmapDrawable) r.getDrawable(R.drawable.ic_wizard_sonetel); sPhoneAppBmp = drawable.getBitmap(); sPhoneAppInfoLoaded = true;/*from ww w .j a v a2 s .c o m*/ } Bundle results = getResultExtras(true); //if(pendingIntent != null) { // results.putParcelable(CallHandlerPlugin.EXTRA_REMOTE_INTENT_TOKEN, pendingIntent); //} results.putString(Intent.EXTRA_TITLE, "Call thru");// context.getResources().getString(R.string.use_pstn)); if (sPhoneAppBmp != null) { results.putParcelable(Intent.EXTRA_SHORTCUT_ICON, sPhoneAppBmp); } if (intent.getStringExtra(Intent.EXTRA_TEXT) == null) return; //final PendingIntent pendingIntent = null; final String callthrunum = intent.getStringExtra(Intent.EXTRA_PHONE_NUMBER); final String dialledNum = intent.getStringExtra(Intent.EXTRA_TEXT); // We must handle that clean way cause when call just to // get the row in account list expect this to reply correctly if (callthrunum != null && PhoneCapabilityTester.isPhone(context)) { if (!callthrunum.equalsIgnoreCase("")) { DBAdapter dbAdapt = new DBAdapter(context); // Build pending intent SipAccount = dbAdapt.getAccount(1); if (SipAccount != null) { Intent i = new Intent(Intent.ACTION_CALL); i.setData(Uri.fromParts("tel", callthrunum, null)); final PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, i, PendingIntent.FLAG_CANCEL_CURRENT); NetWorkThread = new Thread() { public void run() { SendMsgToNetWork(dialledNum, context, pendingIntent); }; }; NetWorkThread.start(); } if (!dialledNum.equalsIgnoreCase("")) { SipCallSessionImpl callInfo = new SipCallSessionImpl(); callInfo.setRemoteContact(dialledNum); callInfo.setIncoming(false); callInfo.callStart = System.currentTimeMillis(); callInfo.setAccId(3); //callInfo.setLastStatusCode(pjsua.PJ_SUCCESS); ContentValues cv = CallLogHelper.logValuesForCall(context, callInfo, callInfo.callStart); context.getContentResolver().insert(SipManager.CALLLOG_URI, cv); } } else { Location_Finder LocFinder = new Location_Finder(context); if (LocFinder.getContryName().startsWith("your")) Toast.makeText(context, "Country of your current location unknown. Call thru not available.", Toast.LENGTH_LONG).show(); else Toast.makeText(context, "No Call thru access number available in " + LocFinder.getContryName(), Toast.LENGTH_LONG).show(); //Toast.makeText(context, "No Call thru access number available in ", Toast.LENGTH_LONG).show(); } } // This will exclude next time tel:xxx is raised from csipsimple treatment which is wanted results.putString(Intent.EXTRA_PHONE_NUMBER, callthrunum); } }