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.liato.bankdroid.banking.banks.Coop.java
@Override public Urllib login() throws LoginException, BankException { try {//from w ww.j a v a 2 s. c o m LoginPackage lp = preLogin(); response = urlopen.open(lp.getLoginTarget(), lp.getPostData()); if (response.contains("forfarande logga in med ditt personnummer")) { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); if (prefs.getBoolean("debug_mode", false) && prefs.getBoolean("debug_coop_sendmail", false)) { Intent i = new Intent(android.content.Intent.ACTION_SEND); i.setType("plain/text"); i.putExtra(android.content.Intent.EXTRA_EMAIL, new String[] { "android@nullbyte.eu" }); i.putExtra(android.content.Intent.EXTRA_SUBJECT, "Bankdroid - Coop Error"); i.putExtra(android.content.Intent.EXTRA_TEXT, response); context.startActivity(i); } throw new LoginException(res.getText(R.string.invalid_username_password).toString()); } } catch (ClientProtocolException e) { throw new BankException(e.getMessage()); } catch (IOException e) { throw new BankException(e.getMessage()); } return urlopen; }
From source file:codepath.watsiapp.utils.Util.java
private static void startShareIntentWithExplicitSocialActivity(Activity ctx, ShareableItem patient, Set<String> socialActivitiesName, String displayName) { Intent shareIntent = new Intent(); shareIntent.setAction(Intent.ACTION_SEND); shareIntent.setType("text/plain"); shareIntent.putExtra(Intent.EXTRA_TEXT, patient.getShareableUrl()); try {/*from www. ja v a 2 s. co m*/ final PackageManager pm = ctx.getPackageManager(); final List activityList = pm.queryIntentActivities(shareIntent, 0); int len = activityList.size(); for (int i = 0; i < len; i++) { final ResolveInfo app = (ResolveInfo) activityList.get(i); Log.d("#####################", app.activityInfo.name); if (socialActivitiesName.contains(app.activityInfo.name)) { final ActivityInfo activity = app.activityInfo; final ComponentName name = new ComponentName(activity.applicationInfo.packageName, activity.name); shareIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED); shareIntent.putExtra(Intent.EXTRA_SUBJECT, "Fund Treatment"); shareIntent.addCategory(Intent.CATEGORY_LAUNCHER); shareIntent.setComponent(name); ctx.startActivity(shareIntent); break; } } } catch (final ActivityNotFoundException e) { Toast.makeText(ctx, "Could not find " + displayName + " app", Toast.LENGTH_SHORT).show(); } }
From source file:com.vladstirbu.cordova.CDVInstagramVideoPlugin.java
private void share(String videoUrl, String captionString) { if (videoUrl != null && videoUrl.length() > 0) { this.webView.loadUrl("javascript:console.log('processing " + videoUrl + "');"); byte[] videoData = null; try {/*from w w w.j a v a 2 s. c om*/ URL url = new URL(videoUrl); URLConnection ucon = url.openConnection(); InputStream is = ucon.getInputStream(); videoData = new byte[is.available()]; is.read(videoData); is.close(); } catch (Exception e) { this.webView.loadUrl("javascript:console.log('" + e.getMessage() + "');"); e.printStackTrace(); } File file = null; FileOutputStream os = null; File parentDir = this.webView.getContext().getExternalFilesDir(null); File[] oldVideos = parentDir.listFiles(OLD_IMAGE_FILTER); for (File oldVideo : oldVideos) { oldVideo.delete(); } try { file = File.createTempFile("instagram_video", ".mp4", parentDir); os = new FileOutputStream(file, true); } catch (Exception e) { this.webView.loadUrl("javascript:console.log('" + e.getMessage() + "');"); e.printStackTrace(); } try { os.write(videoData); os.flush(); os.close(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } Intent shareIntent = new Intent(Intent.ACTION_SEND); shareIntent.setType("video/mp4"); //File media = new File(file); //Uri uri = Uri.fromFile(media); // Add the URI to the Intent. //share.putExtra(Intent.EXTRA_STREAM, uri); // Broadcast the Intent. //startActivity(Intent.createChooser(share, "Share to")); shareIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://" + file)); shareIntent.putExtra(Intent.EXTRA_TEXT, captionString); shareIntent.setPackage("com.instagram.android"); this.cordova.startActivityForResult((CordovaPlugin) this, shareIntent, 12345); } else { this.cbContext.error("Expected one non-empty string argument."); } }
From source file:de.appplant.cordova.emailcomposer.EmailComposerImpl.java
/** * Setter for the body./*from w w w .j a v a 2 s .c om*/ * * @param body * The body of the email. * @param isHTML * Indicates the encoding (HTML or plain text). * @param draft * The intent to send. */ private void setBody(String body, Boolean isHTML, Intent draft) { if (isHTML) { draft.putExtra(Intent.EXTRA_TEXT, Html.fromHtml(body)); draft.setType("text/html"); if (Build.VERSION.SDK_INT > 15) { draft.putExtra(Intent.EXTRA_HTML_TEXT, body); } } else { draft.putExtra(Intent.EXTRA_TEXT, body); draft.setType("text/plain"); } }
From source file:co.taqat.call.AboutFragment.java
private void sendLogs(Context context, String info) { final String appName = context.getString(R.string.app_name); Intent i = new Intent(Intent.ACTION_SEND); i.putExtra(Intent.EXTRA_EMAIL, new String[] { context.getString(R.string.about_bugreport_email) }); i.putExtra(Intent.EXTRA_SUBJECT, appName + " Logs"); i.putExtra(Intent.EXTRA_TEXT, info); i.setType("application/zip"); try {//from w w w . j a v a 2 s .com startActivity(Intent.createChooser(i, "Send mail...")); } catch (android.content.ActivityNotFoundException ex) { Log.e(ex); } }
From source file:ca.rmen.android.networkmonitor.app.dbops.ui.Share.java
/** * Run the given file export, then bring up the chooser intent to share the exported file. * The progress will be displayed in a progress dialog on the given activity. *///from w ww . j av a 2 s . co m private static void shareFile(final FragmentActivity activity, final FileExport fileExport) { Log.v(TAG, "shareFile " + fileExport); Bundle bundle = new Bundle(1); bundle.putString(DBOpAsyncTask.EXTRA_DIALOG_MESSAGE, activity.getString(R.string.export_progress_preparing_export)); new DBOpAsyncTask<File>(activity, fileExport, bundle) { @Override protected File doInBackground(Void... params) { Log.v(TAG, "doInBackground"); File file = null; if (fileExport != null) { if (!Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())) return null; file = super.doInBackground(params); if (file == null) return null; } String reportSummary = SummaryExport.getSummary(activity); // Bring up the chooser to share the file. Intent sendIntent = new Intent(); sendIntent.setAction(Intent.ACTION_SEND); sendIntent.putExtra(Intent.EXTRA_SUBJECT, activity.getString(R.string.export_subject_send_log)); String dateRange = SummaryExport.getDataCollectionDateRange(activity); String messageBody = activity.getString(R.string.export_message_text, dateRange); if (file != null) { sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://" + file.getAbsolutePath())); sendIntent.setType("message/rfc822"); messageBody += activity.getString(R.string.export_message_text_file_attached); } else { sendIntent.setType("text/plain"); } messageBody += reportSummary; sendIntent.putExtra(Intent.EXTRA_TEXT, messageBody); activity.startActivity( Intent.createChooser(sendIntent, activity.getResources().getText(R.string.action_share))); return file; } @Override protected void onPostExecute(File result) { Log.v(TAG, "onPostExecute"); // Show a toast if we failed to export a file. if (fileExport != null && result == null) Toast.makeText(activity, R.string.export_error_sdcard_unmounted, Toast.LENGTH_LONG).show(); super.onPostExecute(result); } }.execute(); }
From source file:com.pixellostudio.qqdroid.BaseQuote.java
public boolean onContextItemSelected(MenuItem item) { switch (item.getItemId()) { case 1://from w w w . ja va 2 s . c o m AdapterView.AdapterContextMenuInfo menuInfo = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo(); Spanned quote = Html.fromHtml((String) view.getAdapter().getItem(menuInfo.position)); Intent i = new Intent(Intent.ACTION_SEND); i.putExtra(Intent.EXTRA_TEXT, getBaseContext().getText(R.string.quotefrom) + " " + name + " : " + quote); i.setType("text/plain"); startActivity(Intent.createChooser(i, this.getText(R.string.share))); break; default: return super.onContextItemSelected(item); } return true; }
From source file:info.semanticsoftware.semassist.android.activity.SemanticAssistantsActivity.java
/** Sets the user interface and retrieves the list of * available services.//from w w w .j av a 2 s .c om * @param savedInstanceState saved instance state */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Find the user preferred Semantic Assistants server serverURL = readServerSettings(); // Retrieve the list of available assistants getServicesTask task = new getServicesTask(); Log.i(TAG, "Retrieving available assistants from " + serverURL); task.execute(serverURL); // while the task is being executed, create the user interface setContentView(R.layout.main); lblAvAssist = (TextView) findViewById(R.id.lblAvAssist); txtInput = (EditText) findViewById(R.id.txtInput); // catch the text sent from another app on the system if (Intent.ACTION_SEND.equals(getIntent().getAction())) { Bundle bundle = getIntent().getExtras(); txtInput.setText(bundle.getString(Intent.EXTRA_TEXT)); getIntent().setAction(null); } btnClear = (Button) findViewById(R.id.btnClear); btnClear.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { txtInput.setText(""); } }); }
From source file:com.google.android.apps.muzei.featuredart.FeaturedArtSource.java
@Override protected void onCustomCommand(int id) { super.onCustomCommand(id); if (COMMAND_ID_SHARE == id) { Artwork currentArtwork = getCurrentArtwork(); if (currentArtwork == null) { LOGW(TAG, "No current artwork, can't share."); new Handler(Looper.getMainLooper()).post(new Runnable() { @Override/*from w w w.j a v a 2 s . co m*/ public void run() { Toast.makeText(FeaturedArtSource.this, R.string.featuredart_source_error_no_artwork_to_share, Toast.LENGTH_SHORT).show(); } }); return; } String detailUrl = ("initial".equals(currentArtwork.getToken())) ? "http://www.wikipaintings.org/en/vincent-van-gogh/the-starry-night-1889" : currentArtwork.getViewIntent().getDataString(); String artist = currentArtwork.getByline().replaceFirst("\\.\\s*($|\\n).*", "").trim(); Intent shareIntent = new Intent(Intent.ACTION_SEND); shareIntent.setType("text/plain"); shareIntent.putExtra(Intent.EXTRA_TEXT, "My Android wallpaper today is '" + currentArtwork.getTitle().trim() + "' by " + artist + ". #MuzeiFeaturedArt\n\n" + detailUrl); shareIntent = Intent.createChooser(shareIntent, "Share artwork"); shareIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(shareIntent); } else if (COMMAND_ID_DEBUG_INFO == id) { long nextUpdateTimeMillis = getSharedPreferences().getLong("scheduled_update_time_millis", 0); final String nextUpdateTime; if (nextUpdateTimeMillis > 0) { Date d = new Date(nextUpdateTimeMillis); nextUpdateTime = SimpleDateFormat.getDateTimeInstance().format(d); } else { nextUpdateTime = "None"; } new Handler(Looper.getMainLooper()).post(new Runnable() { @Override public void run() { Toast.makeText(FeaturedArtSource.this, "Next update time: " + nextUpdateTime, Toast.LENGTH_LONG) .show(); } }); } }