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:com.andrewshu.android.reddit.submit.SubmitLinkActivity.java
/** * Enable the UI after user is logged in. *//*ww w . j av a 2 s . c o m*/ private void start() { // Intents can be external (browser share page) or from Reddit is fun. String intentAction = getIntent().getAction(); if (Intent.ACTION_SEND.equals(intentAction)) { // Share Bundle extras = getIntent().getExtras(); if (extras != null) { String url = extras.getString(Intent.EXTRA_TEXT); final EditText submitLinkUrl = (EditText) findViewById(R.id.submit_link_url); final EditText submitLinkReddit = (EditText) findViewById(R.id.submit_link_reddit); final EditText submitTextReddit = (EditText) findViewById(R.id.submit_text_reddit); submitLinkUrl.setText(url); submitLinkReddit.setText(""); submitTextReddit.setText(""); mSubmitUrl = Constants.REDDIT_BASE_URL + "/submit"; } } else { String submitPath = null; Uri data = getIntent().getData(); if (data != null && Util.isRedditUri(data)) submitPath = data.getPath(); if (submitPath == null) submitPath = "/submit"; // the URL to do HTTP POST to mSubmitUrl = Util.absolutePathToURL(submitPath); // Put the subreddit in the text field final EditText submitLinkReddit = (EditText) findViewById(R.id.submit_link_reddit); final EditText submitTextReddit = (EditText) findViewById(R.id.submit_text_reddit); Matcher m = SUBMIT_PATH_PATTERN.matcher(submitPath); if (m.matches()) { String subreddit = m.group(1); if (StringUtils.isEmpty(subreddit)) { submitLinkReddit.setText(""); submitTextReddit.setText(""); } else { submitLinkReddit.setText(subreddit); submitTextReddit.setText(subreddit); } } } final Button submitLinkButton = (Button) findViewById(R.id.submit_link_button); submitLinkButton.setOnClickListener(new OnClickListener() { public void onClick(View v) { if (validateLinkForm()) { final EditText submitLinkTitle = (EditText) findViewById(R.id.submit_link_title); final EditText submitLinkUrl = (EditText) findViewById(R.id.submit_link_url); final EditText submitLinkReddit = (EditText) findViewById(R.id.submit_link_reddit); final EditText submitLinkCaptcha = (EditText) findViewById(R.id.submit_link_captcha); new SubmitLinkTask(submitLinkTitle.getText().toString(), submitLinkUrl.getText().toString(), submitLinkReddit.getText().toString(), Constants.SUBMIT_KIND_LINK, submitLinkCaptcha.getText().toString()).execute(); } } }); final Button submitTextButton = (Button) findViewById(R.id.submit_text_button); submitTextButton.setOnClickListener(new OnClickListener() { public void onClick(View v) { if (validateTextForm()) { final EditText submitTextTitle = (EditText) findViewById(R.id.submit_text_title); final EditText submitTextText = (EditText) findViewById(R.id.submit_text_text); final EditText submitTextReddit = (EditText) findViewById(R.id.submit_text_reddit); final EditText submitTextCaptcha = (EditText) findViewById(R.id.submit_text_captcha); new SubmitLinkTask(submitTextTitle.getText().toString(), submitTextText.getText().toString(), submitTextReddit.getText().toString(), Constants.SUBMIT_KIND_SELF, submitTextCaptcha.getText().toString()).execute(); } } }); // Check the CAPTCHA new MyCaptchaCheckRequiredTask().execute(); }
From source file:ch.luklanis.esscan.history.HistoryActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.history_menu_send_dta_save: case R.id.history_menu_send_dta_other: case R.id.history_menu_send_dta_email: { Message message = Message.obtain(mDataSentHandler, item.getItemId()); createDTAFile(message);//from w ww. j av a2s . co m } break; case R.id.history_menu_send_csv: { CharSequence history = mHistoryManager.buildHistory(); Uri historyFile = HistoryManager.saveHistory(history.toString()); String[] recipients = new String[] { PreferenceManager.getDefaultSharedPreferences(this) .getString(PreferencesActivity.KEY_EMAIL_ADDRESS, "") }; if (historyFile == null) { setOkAlert(R.string.msg_unmount_usb); } else { Intent intent = new Intent(Intent.ACTION_SEND, Uri.parse("mailto:")); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); intent.putExtra(Intent.EXTRA_EMAIL, recipients); String subject = getResources().getString(R.string.history_email_title); intent.putExtra(Intent.EXTRA_SUBJECT, subject); intent.putExtra(Intent.EXTRA_TEXT, subject); intent.putExtra(Intent.EXTRA_STREAM, historyFile); intent.setType("text/csv"); startActivity(intent); } } break; case R.id.history_menu_clear: { new CancelOkDialog(R.string.msg_sure).setOkClickListener(new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { mHistoryManager.clearHistory(); dialogInterface.dismiss(); finish(); } }).show(getFragmentManager(), "HistoryActivity.onOptionsItemSelected"); } break; case android.R.id.home: { int error = PsDetailActivity.savePaymentSlip(this); if (error > 0) { setCancelOkAlert(this, error); return true; } NavUtils.navigateUpTo(this, new Intent(this, CaptureActivity.class)); return true; } case R.id.history_menu_copy_code_row: { PsDetailFragment fragment = (PsDetailFragment) getFragmentManager() .findFragmentById(R.id.ps_detail_container); if (fragment != null) { String completeCode = fragment.getHistoryItem().getResult().getCompleteCode(); addCodeRowToClipboard(completeCode); } } break; case R.id.history_menu_send_code_row: { PsDetailFragment fragment = (PsDetailFragment) getFragmentManager() .findFragmentById(R.id.ps_detail_container); if (fragment != null) { IEsrSender sender = getEsrSender(); if (sender != null) { mSendingProgressDialog.show(); fragment.send(PsDetailFragment.SEND_COMPONENT_CODE_ROW, sender, this.historyFragment.getActivatedPosition()); } else { Message message = Message.obtain(mDataSentHandler, R.id.es_send_failed); message.sendToTarget(); } } } break; default: return super.onOptionsItemSelected(item); } return true; }
From source file:org.tomahawk.tomahawk_android.utils.TomahawkExceptionReporter.java
/** * Pull information from the given {@link CrashReportData} and send it via HTTP to * oops.tomahawk-player.org or sends it as a TEXT intent, if IS_SILENT is true *//* w ww . j ava 2 s. co m*/ @Override public void send(CrashReportData data) throws ReportSenderException { StringBuilder body = new StringBuilder(); List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2); nameValuePairs.add(new BasicNameValuePair("Version", data.getProperty(ReportField.APP_VERSION_NAME))); nameValuePairs.add(new BasicNameValuePair("BuildID", data.getProperty(ReportField.BUILD))); nameValuePairs.add(new BasicNameValuePair("ProductName", "tomahawk-android")); nameValuePairs.add(new BasicNameValuePair("Vendor", "Tomahawk")); nameValuePairs.add(new BasicNameValuePair("timestamp", data.getProperty(ReportField.USER_CRASH_DATE))); for (NameValuePair pair : nameValuePairs) { body.append("--thkboundary\r\n"); body.append("Content-Disposition: form-data; name=\""); body.append(pair.getName()).append("\"\r\n\r\n").append(pair.getValue()).append("\r\n"); } body.append("--thkboundary\r\n"); body.append("Content-Disposition: form-data; name=\"upload_file_minidump\"; filename=\"") .append(data.getProperty(ReportField.REPORT_ID)).append("\"\r\n"); body.append("Content-Type: application/octet-stream\r\n\r\n"); body.append("============== Tomahawk Exception Report ==============\r\n\r\n"); body.append("Report ID: ").append(data.getProperty(ReportField.REPORT_ID)).append("\r\n"); body.append("App Start Date: ").append(data.getProperty(ReportField.USER_APP_START_DATE)).append("\r\n"); body.append("Crash Date: ").append(data.getProperty(ReportField.USER_CRASH_DATE)).append("\r\n\r\n"); body.append("--------- Phone Details ----------\r\n"); body.append("Phone Model: ").append(data.getProperty(ReportField.PHONE_MODEL)).append("\r\n"); body.append("Brand: ").append(data.getProperty(ReportField.BRAND)).append("\r\n"); body.append("Product: ").append(data.getProperty(ReportField.PRODUCT)).append("\r\n"); body.append("Display: ").append(data.getProperty(ReportField.DISPLAY)).append("\r\n"); body.append("-----------------------------------\r\n\r\n"); body.append("----------- Stack Trace -----------\r\n"); body.append(data.getProperty(ReportField.STACK_TRACE)).append("\r\n"); body.append("-----------------------------------\r\n\r\n"); body.append("------- Operating System ---------\r\n"); body.append("App Version Name: ").append(data.getProperty(ReportField.APP_VERSION_NAME)).append("\r\n"); body.append("Total Mem Size: ").append(data.getProperty(ReportField.TOTAL_MEM_SIZE)).append("\r\n"); body.append("Available Mem Size: ").append(data.getProperty(ReportField.AVAILABLE_MEM_SIZE)).append("\r\n"); body.append("Dumpsys Meminfo: ").append(data.getProperty(ReportField.DUMPSYS_MEMINFO)).append("\r\n"); body.append("-----------------------------------\r\n\r\n"); body.append("-------------- Misc ---------------\r\n"); body.append("Package Name: ").append(data.getProperty(ReportField.PACKAGE_NAME)).append("\r\n"); body.append("File Path: ").append(data.getProperty(ReportField.FILE_PATH)).append("\r\n"); body.append("Android Version: ").append(data.getProperty(ReportField.ANDROID_VERSION)).append("\r\n"); body.append("Build: ").append(data.getProperty(ReportField.BUILD)).append("\r\n"); body.append("Initial Configuration: ").append(data.getProperty(ReportField.INITIAL_CONFIGURATION)) .append("\r\n"); body.append("Crash Configuration: ").append(data.getProperty(ReportField.CRASH_CONFIGURATION)) .append("\r\n"); body.append("Settings Secure: ").append(data.getProperty(ReportField.SETTINGS_SECURE)).append("\r\n"); body.append("User Email: ").append(data.getProperty(ReportField.USER_EMAIL)).append("\r\n"); body.append("User Comment: ").append(data.getProperty(ReportField.USER_COMMENT)).append("\r\n"); body.append("-----------------------------------\r\n\r\n"); body.append("---------------- Logs -------------\r\n"); body.append("Logcat: ").append(data.getProperty(ReportField.LOGCAT)).append("\r\n\r\n"); body.append("Events Log: ").append(data.getProperty(ReportField.EVENTSLOG)).append("\r\n\r\n"); body.append("Radio Log: ").append(data.getProperty(ReportField.RADIOLOG)).append("\r\n"); body.append("-----------------------------------\r\n\r\n"); body.append("=======================================================\r\n\r\n"); body.append("--thkboundary\r\n"); body.append( "Content-Disposition: form-data; name=\"upload_file_tomahawklog\"; filename=\"Tomahawk.log\"\r\n"); body.append("Content-Type: text/plain\r\n\r\n"); body.append(data.getProperty(ReportField.LOGCAT)); body.append("\r\n--thkboundary--\r\n"); if ("true".equals(data.getProperty(ReportField.IS_SILENT))) { Intent intent = new Intent(Intent.ACTION_SEND); intent.setType("text/plain"); body.insert(0, "Please tell us why you're sending us this log:\n\n\n\n\n"); intent.putExtra(Intent.EXTRA_TEXT, body.toString()); intent.putExtra(Intent.EXTRA_EMAIL, new String[] { "support@tomahawk-player.org" }); intent.putExtra(Intent.EXTRA_SUBJECT, "Tomahawk Android Log"); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); TomahawkApp.getContext().startActivity(intent); } else { HttpClient httpclient = new DefaultHttpClient(); HttpPost httppost = new HttpPost("http://oops.tomahawk-player.org/addreport.php"); httppost.setHeader("Content-type", "multipart/form-data; boundary=thkboundary"); try { httppost.setEntity(new StringEntity(body.toString())); httpclient.execute(httppost); } catch (ClientProtocolException e) { Log.e(TAG, "send: " + e.getClass() + ": " + e.getLocalizedMessage()); } catch (IOException e) { Log.e(TAG, "send: " + e.getClass() + ": " + e.getLocalizedMessage()); } } }
From source file:com.google.android.apps.iosched2.service.SyncService.java
@Override protected void onHandleIntent(Intent intent) { Log.d(TAG, "onHandleIntent(intent=" + intent.toString() + ")"); final ResultReceiver receiver = intent.getParcelableExtra(EXTRA_STATUS_RECEIVER); if (receiver != null) receiver.send(STATUS_RUNNING, Bundle.EMPTY); final Context context = this; final SharedPreferences prefs = getSharedPreferences(Prefs.SCHED_SYNC, Context.MODE_PRIVATE); final int localVersion = prefs.getInt(Prefs.LOCAL_VERSION, VERSION_NONE); try {//from w w w . j a v a2s .co m // Bulk of sync work, performed by executing several fetches from // local and online sources. final long startLocal = System.currentTimeMillis(); final boolean localParse = localVersion < VERSION_CURRENT; Log.d(TAG, "found localVersion=" + localVersion + " and VERSION_CURRENT=" + VERSION_CURRENT); if (localParse) { // Load static local data mLocalExecutor.execute(Setup.BLOCKS_XML, new LocalBlocksHandler()); mLocalExecutor.execute(Setup.ROOMS_XML, new LocalRoomsHandler()); // mLocalExecutor.execute(R.xml.blocks, new LocalBlocksHandler()); // mLocalExecutor.execute(R.xml.rooms, new LocalRoomsHandler()); mLocalExecutor.execute(R.xml.tracks, new LocalTracksHandler()); mLocalExecutor.execute(R.xml.search_suggest, new LocalSearchSuggestHandler()); mLocalExecutor.execute(R.xml.sessions, new LocalSessionsHandler()); // Parse values from local cache first, since spreadsheet copy // or network might be down. mLocalExecutor.execute(context, Setup.EVENT_PREFIX + "cache-sessions.xml", new RemoteSessionsHandler()); mLocalExecutor.execute(context, Setup.EVENT_PREFIX + "cache-speakers.xml", new RemoteSpeakersHandler()); if (Setup.FEATURE_VENDORS_ON) { mLocalExecutor.execute(context, Setup.EVENT_PREFIX + "cache-vendors.xml", new RemoteVendorsHandler()); } // Save local parsed version prefs.edit().putInt(Prefs.LOCAL_VERSION, VERSION_CURRENT).commit(); } Log.d(TAG, "local sync took " + (System.currentTimeMillis() - startLocal) + "ms"); // Always hit remote spreadsheet for any updates final long startRemote = System.currentTimeMillis(); mRemoteExecutor.executeGet(WORKSHEETS_URL, new RemoteWorksheetsHandler(mRemoteExecutor)); Log.d(TAG, "remote sync took " + (System.currentTimeMillis() - startRemote) + "ms"); } catch (Exception e) { Log.e(TAG, "Problem while syncing", e); if (receiver != null) { // Pass back error to surface listener final Bundle bundle = new Bundle(); bundle.putString(Intent.EXTRA_TEXT, e.toString()); receiver.send(STATUS_ERROR, bundle); } } // Announce success to any surface listener Log.d(TAG, "sync finished"); if (receiver != null) receiver.send(STATUS_FINISHED, Bundle.EMPTY); }
From source file:com.ae.apps.messagecounter.activities.MainActivity.java
private Intent getShareIntent() { Intent shareIntent = new Intent(); shareIntent.setAction(Intent.ACTION_SEND); shareIntent.setType("text/plain"); shareIntent.putExtra(Intent.EXTRA_TEXT, getResources().getString(R.string.play_store_url)); return shareIntent; }
From source file:com.codebutler.farebot.fragment.CardsFragment.java
@Override public boolean onOptionsItemSelected(MenuItem item) { ClipboardManager clipboardManager = (ClipboardManager) getActivity() .getSystemService(Context.CLIPBOARD_SERVICE); try {/*from ww w .jav a 2s .com*/ int itemId = item.getItemId(); switch (itemId) { case R.id.import_file: Intent target = new Intent(Intent.ACTION_GET_CONTENT); target.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(Environment.getExternalStorageDirectory())); target.setType("*/*"); startActivityForResult(Intent.createChooser(target, getString(R.string.select_file)), REQUEST_SELECT_FILE); return true; case R.id.import_clipboard: ClipData clip = clipboardManager.getPrimaryClip(); if (clip != null && clip.getItemCount() > 0) { String text = clip.getItemAt(0).coerceToText(getActivity()).toString(); onCardsImported(mExportHelper.importCards(text)); } return true; case R.id.copy: clipboardManager.setPrimaryClip(ClipData.newPlainText(null, mExportHelper.exportCards())); Toast.makeText(getActivity(), R.string.copied_to_clipboard, Toast.LENGTH_SHORT).show(); return true; case R.id.share: Intent intent = new Intent(Intent.ACTION_SEND); intent.setType("text/plain"); intent.putExtra(Intent.EXTRA_TEXT, mExportHelper.exportCards()); startActivity(intent); return true; case R.id.save: exportToFile(); return true; } } catch (Exception ex) { Utils.showError(getActivity(), ex); } return false; }
From source file:it.mb.whatshare.SendToGCMActivity.java
@Override protected void onNewIntent(final Intent intent) { tracker = GoogleAnalytics.getInstance(this).getDefaultTracker(); if (intent.hasExtra(Intent.EXTRA_TEXT)) { if (!Utils.isConnectedToTheInternet(this)) { Dialogs.noInternetConnection(this, R.string.no_internet_sending, true); } else {//from w w w . j a va 2 s . com // send to paired device if any try { if (outboundDevice == null) { Pair<PairedDevice, String> paired = loadOutboundPairing(this); if (paired != null) outboundDevice = paired.first; } if (outboundDevice != null) { // share with other device shareViaGCM(intent); finish(); return; } } catch (OptionalDataException e) { e.printStackTrace(); } catch (ClassNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } // can't load paired device from file tracker.sendEvent("intent", "send_to_gcm", "no_paired_device", 0L); Dialogs.noPairedDevice(this); } } else { // user clicked on the notification notificationCounter.set(0); finish(); } }
From source file:com.z.stproperty.PropertyDetailFragment.java
/** * onClick :: OnClickListener//from w w w . java 2s . co m * * Is common on-click listener for all the buttons and images in home screen * This is grouped into single listener to make easier to alter the code and reduce the * line of code. * * This will check the View ID to match with the predefined View-ID to identify * which view is clicked * * Based on the view id this will perform different functionalities */ private void performClickAction(View v) { try { switch (v.getId()) { case R.id.LoanCalculator: Intent calIntent = new Intent(getActivity(), LoanCalculator.class); calIntent.putExtra("price", price); startActivity(calIntent); break; case R.id.AgentMobile: String url = "tel:" + mobileNoStr; url = url.replace("+65-", ""); Intent callIntent = new Intent(Intent.ACTION_CALL); callIntent.setData(Uri.parse(url)); startActivity(callIntent); break; case R.id.SendEmailBtn: String text = "I'm interested in your property advertised on STProperty\n\n" + "PROPERTY TITLE:" + title + "\n" + "PRICE:" + price + "\n\nClick on the following link to view more details about the property\n\n" + prurl; Intent intent = new Intent(Intent.ACTION_SEND); intent.setType("plain/text"); intent.putExtra(Intent.EXTRA_EMAIL, new String[] { agentEmail }); intent.putExtra(Intent.EXTRA_SUBJECT, "Enquiry"); intent.putExtra(Intent.EXTRA_TEXT, text); SharedFunction.postAnalytics(PropertyDetailFragment.this.getActivity(), "Lead", "Successful Email Enquiry", title); startActivity(Intent.createChooser(intent, "")); break; /**case R.id.SendEnquiryBtn: Intent enqInt = new Intent(getActivity(), SaleEnquiry.class); enqInt.putExtra("propertyId", detailsJson.getString("id")); enqInt.putExtra("agentId", detailsJson.getJSONObject("seller_info").getString("agent_cea_reg_no")); startActivity(enqInt); break;*/ default: break; } } catch (Exception e) { Log.e(this.getClass().getSimpleName(), e.getLocalizedMessage(), e); } }
From source file:com.galois.qrstream.MainActivity.java
private Job buildJobFromIntent(Intent intent) throws IllegalArgumentException { String type = intent.getType(); Bundle extras = intent.getExtras();/*ww w .ja va2 s . co m*/ Log.d(Constants.APP_TAG, "** received type " + type); String name = ""; byte[] bytes = null; Uri dataUrl = (Uri) intent.getExtras().getParcelable(Intent.EXTRA_STREAM); if (dataUrl != null) { name = getNameFromURI(dataUrl); if (dataUrl.getScheme().equals("content") || dataUrl.getScheme().equals("file")) { try { bytes = readFileUri(dataUrl); } catch (IOException e) { e.printStackTrace(); } } else { Log.d(Constants.APP_TAG, "unsupported url: " + dataUrl); } } else { // fall back to content in extras (mime type dependent) if (type.equals("text/plain")) { String subject = extras.getString(Intent.EXTRA_SUBJECT); String text = extras.getString(Intent.EXTRA_TEXT); if (subject == null) { bytes = text.getBytes(); } else { bytes = encodeSubjectAndText(subject, text); type = Constants.MIME_TYPE_TEXT_NOTE; } } } return new Job(name, bytes, type); }
From source file:im.delight.android.commons.Social.java
/** * Displays an application chooser and composes the described text message (SMS) using the selected application * * @param recipientPhone the recipient's phone number or `null` * @param bodyText the body text of the message * @param captionRes a string resource ID for the title of the application chooser's window * @param context a context reference/*from www.ja v a2s . c o m*/ * @throws Exception if there was an error trying to launch the SMS application */ public static void sendSms(final String recipientPhone, final String bodyText, final int captionRes, final Context context) throws Exception { final Intent intent = new Intent(Intent.ACTION_SENDTO); intent.setType(HTTP.PLAIN_TEXT_TYPE); if (recipientPhone != null && recipientPhone.length() > 0) { intent.setData(Uri.parse("smsto:" + recipientPhone)); } else { intent.setData(Uri.parse("sms:")); } intent.putExtra("sms_body", bodyText); intent.putExtra(Intent.EXTRA_TEXT, bodyText); if (context != null) { // offer a selection of all applications that can handle the SMS Intent context.startActivity(Intent.createChooser(intent, context.getString(captionRes))); } }