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.example.tomk.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 = {};/* w w w . j av a 2s. c o m*/ 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); View rootView = inflater.inflate(R.layout.fragment_my, 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<?> adapterView, View view, int position, long l) { String forecast = mForecastAdapter.getItem(position); Intent detailIntent = new Intent(getActivity(), DetailActivity.class).putExtra(Intent.EXTRA_TEXT, forecast); startActivity(detailIntent); } }); return rootView; }
From source file:com.samuelcastro.cordova.InstagramSharePlugin.java
private void shareImage(String imageString, String captionString) { if (imageString != null && imageString.length() > 0) { byte[] imageData = Base64.decode(imageString, 0); File file = null;//from w w w. j av a 2 s . c o m FileOutputStream os = null; File parentDir = this.webView.getContext().getExternalFilesDir(null); File[] oldImages = parentDir.listFiles(OLD_IMAGE_FILTER); for (File oldImage : oldImages) { oldImage.delete(); } try { file = File.createTempFile("instagram", ".png", parentDir); os = new FileOutputStream(file, true); } catch (Exception e) { e.printStackTrace(); } try { os.write(imageData); os.flush(); os.close(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } Intent shareIntent = new Intent(Intent.ACTION_SEND); shareIntent.setType("image/*"); 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:edu.mit.mobile.android.livingpostcards.data.Card.java
/** * Creates an {@link Intent#ACTION_SEND} intent to share the given card. * * @param context/* w ww . ja v a 2 s. c o m*/ * @param webUrl * the content of the card's {@link Card#COL_WEB_URL} field. Can be a relative URL. * @param title * the title of the card * @return an intent, within a chooser, that can be used with * {@link Context#startActivity(Intent)} */ public static Intent createShareIntent(Context context, String webUrl, CharSequence title) { final NetworkClient nc = LocastApplication.getNetworkClient(context, Authenticator.getFirstAccount(context)); final Intent sendIntent = new Intent(Intent.ACTION_SEND); sendIntent.setType("text/plain"); sendIntent.putExtra(Intent.EXTRA_TEXT, context.getString(R.string.send_intent_message, nc.getFullUrlAsString(webUrl))); sendIntent.putExtra(Intent.EXTRA_SUBJECT, context.getString(R.string.send_intent_subject, title)); return Intent.createChooser(sendIntent, context.getString(R.string.send_intent_chooser_title)); }
From source file:org.mrquiz.android.tinyurl.SendTinyUrlActivity.java
private void send() { Intent intent = new Intent(Intent.ACTION_SEND); intent.setType("text/plain"); Intent originalIntent = getIntent(); if (Intent.ACTION_SEND.equals(originalIntent.getAction())) { // Copy extras from the original intent because they miht contain // additional information about the URL (e.g., the title of a // YouTube video). Do this before setting Intent.EXTRA_TEXT to avoid // overwriting the TinyShare. intent.putExtras(originalIntent.getExtras()); }// ww w . j a v a 2s . c o m intent.putExtra(Intent.EXTRA_TEXT, mTinyUrl); try { CharSequence template = getText(R.string.title_send); String title = String.format(String.valueOf(template), mTinyUrl); startActivity(Intent.createChooser(intent, title)); } catch (ActivityNotFoundException e) { handleError(e); } }
From source file:com.krayzk9s.imgurholo.services.UploadService.java
public void onGetObject(Object o, String tag) { String id = (String) o; if (id.length() == 7) { if (totalUpload != -1) ids.add(id);/* w w w . ja v a 2 s.com*/ if (ids.size() == totalUpload) { ids.add(0, ""); //weird hack because imgur eats the first item of the array for some bizarre reason NewAlbumAsync newAlbumAsync = new NewAlbumAsync("", "", apiCall, ids, this); newAlbumAsync.execute(); } } else if (apiCall.settings.getBoolean("AlbumUpload", true)) { NotificationManager notificationManager = (NotificationManager) this .getSystemService(Context.NOTIFICATION_SERVICE); NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this); Intent viewImageIntent = new Intent(); viewImageIntent.setAction(Intent.ACTION_VIEW); viewImageIntent.setData(Uri.parse("http://imgur.com/a/" + id)); Intent shareIntent = new Intent(); shareIntent.setType("text/plain"); shareIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); shareIntent.putExtra(Intent.EXTRA_TEXT, "http://imgur.com/a/" + id); PendingIntent viewImagePendingIntent = PendingIntent.getActivity(this, (int) System.currentTimeMillis(), viewImageIntent, 0); PendingIntent sharePendingIntent = PendingIntent.getActivity(this, (int) System.currentTimeMillis(), shareIntent, 0); Notification notification = notificationBuilder.setSmallIcon(R.drawable.icon_desaturated) .setContentText("Finished Uploading Album").setContentTitle("imgur Image Uploader") .setContentIntent(viewImagePendingIntent) .addAction(R.drawable.dark_social_share, "Share", sharePendingIntent).build(); Log.d("Built", "Notification built"); notificationManager.cancel(0); notificationManager.notify(1, notification); Log.d("Built", "Notification display"); } else { NotificationManager notificationManager = (NotificationManager) this .getSystemService(Context.NOTIFICATION_SERVICE); NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this); Notification notification = notificationBuilder.setSmallIcon(R.drawable.icon_desaturated) .setContentText("Finished Uploading All Images").setContentTitle("imgur Image Uploader") .build(); Log.d("Built", "Notification built"); notificationManager.cancel(0); notificationManager.notify(1, notification); Log.d("Built", "Notification display"); } }
From source file:de.damdi.fitness.activity.settings.sync.OpenTrainingSyncService.java
protected void onHandleIntent(Intent intent) { Log.d(TAG, "onHandleIntent()"); version = intent.getIntExtra(EXTRA_VERSION_CODE, -1); host = intent.getStringExtra(EXTRA_HOST); mReceiver = intent.getParcelableExtra("receiver"); String command = intent.getStringExtra("command"); Bundle b = new Bundle(); if (command.equals("query")) { try {// w w w . j av a 2 s . co m // set up REST-Client mClient = new RestClient(host, port, "https", version); // download and parse the exercises ArrayList<ExerciseType> allExercises = downloadAndParseExercises(); // add data to bundle b.putSerializable("all_exercises", allExercises); mReceiver.send(STATUS_FINISHED, b); } catch (Exception e) { Log.e(TAG, "Error, could not get exercises from server: " + e.toString(), e); b.putString(Intent.EXTRA_TEXT, e.toString()); mReceiver.send(STATUS_ERROR, b); } } this.stopSelf(); }
From source file:com.hybris.mobile.activity.AbstractProductDetailActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { boolean handled = super.onOptionsItemSelected(item); if (!handled) { // Put custom menu items handlers here switch (item.getItemId()) { // NFC writing is for debug use only case R.id.write_tag: if (NFCUtil.canNFC(this)) { Intent writeIntent = new Intent(this, NFCWriteActivity.class); NdefMessage msg = getNDEF(mProduct.getCode()); writeIntent.putExtra(NFCWriteActivity.NDEF_MESSAGE, msg); startActivity(writeIntent); } else { Toast.makeText(this, R.string.error_nfc_not_supported, Toast.LENGTH_LONG).show(); }//from w w w.j ava 2 s. c o m return true; case R.id.share: try { Intent sendIntent = new Intent(); sendIntent.setAction(Intent.ACTION_SEND); sendIntent.putExtra(Intent.EXTRA_TEXT, mProduct.getName() + " - " + getString(R.string.nfc_url, URLEncoder.encode(mProduct.getCode(), "UTF-8"))); sendIntent.setType("text/plain"); startActivity(Intent.createChooser(sendIntent, getString(R.string.share_dialog_title))); } catch (UnsupportedEncodingException e) { LoggingUtils.e(LOG_TAG, "Error trying to encode product code to UTF-8. " + e.getLocalizedMessage(), Hybris.getAppContext()); } return true; default: return false; } } return handled; }
From source file:br.com.PartoHumanizado.fragment.EnviarPlanoDePartoFragment.java
@OnClick(R.id.enviar) public void enviar() { Intent intent = new Intent(Intent.ACTION_SEND); intent.setType("message/rfc822"); // intent.setType("text/plain"); intent.putExtra(Intent.EXTRA_EMAIL, ""); intent.putExtra(Intent.EXTRA_SUBJECT, "Plano de Parto"); intent.putExtra(Intent.EXTRA_TEXT, texto.getText().toString()); startActivity(Intent.createChooser(intent, "Enviar email")); // startActivity(intent); }
From source file:activeng.pt.activenglab.BluetoothChatService.java
/** * Constructor. Prepares a new BluetoothChat session. * * @param context The UI Activity Context *//*from w w w .j a v a 2 s. co m*/ //public BluetoothChatService(Context context, Handler handler) { public BluetoothChatService(Context context) { mContext = context; mAdapter = BluetoothAdapter.getDefaultAdapter(); mState = Constants.STATE_NONE; //mHandler = handler; connectionUpdates = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { Bundle extras = intent.getExtras(); Log.d("ActivEng", "BluetoothChatService --> onReceive"); if (extras != null) { String message = extras.getString(Intent.EXTRA_TEXT); Log.d("ActivEng", message); write(message + "\n"); } } }; }
From source file:com.elkriefy.android.apps.chubbytabby.activity.MainActivity.java
private PendingIntent createPendingEmailIntent() { Intent emailIntent = new Intent(Intent.ACTION_SENDTO, Uri.fromParts("mailto", "example@example.com", null)); emailIntent.putExtra(Intent.EXTRA_SUBJECT, "Subject"); emailIntent.putExtra(Intent.EXTRA_TEXT, "Body"); return PendingIntent.getActivity(getApplicationContext(), 0, emailIntent, 0); }