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:net.gromgull.android.bibsonomyposter.BibsonomyPosterActivity.java
/** Called with the activity is first created. */ @Override//from ww w.j ava 2s .c o m public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); load(); Intent intent = getIntent(); String action = intent.getAction(); if (action.equalsIgnoreCase(Intent.ACTION_SEND)) { final String uri = intent.getStringExtra(Intent.EXTRA_TEXT); final String title = intent.getStringExtra(Intent.EXTRA_SUBJECT); final Context context = getApplicationContext(); new AsyncTask<Void, Integer, Boolean>() { @Override protected Boolean doInBackground(Void... v) { try { bookmark(uri, title); return true; } catch (Exception e) { Log.w(LOGTAG, "Could not bookmark: " + title + " / " + uri, e); return false; } } protected void onPostExecute(Boolean result) { if (result) { Toast toast = Toast.makeText(context, "Bookmarked " + title, Toast.LENGTH_SHORT); toast.show(); } else { Toast toast = Toast.makeText(context, "Error bookmarking " + title, Toast.LENGTH_SHORT); toast.show(); } } }.execute(); finish(); return; } // Inflate our UI from its XML layout description. setContentView(R.layout.bibsonomyposter_activity); if (username != null) ((EditText) findViewById(R.id.username)).setText(username); if (apikey != null) ((EditText) findViewById(R.id.apikey)).setText(apikey); // Hook up button presses to the appropriate event handler. ((Button) findViewById(R.id.save)).setOnClickListener(mSaveListener); }
From source file:com.granita.contacticloudsync.ui.DebugInfoActivity.java
public void onShare(MenuItem item) { if (!TextUtils.isEmpty(report)) { Intent sendIntent = new Intent(); sendIntent.setAction(Intent.ACTION_SEND); sendIntent.setType("text/plain"); sendIntent.putExtra(Intent.EXTRA_SUBJECT, "Exception Details"); try {//ww w. j a v a 2s . c o m File reportFile = File.createTempFile("debug", ".txt", getExternalCacheDir()); Constants.log.debug("Writing debug info to " + reportFile.getAbsolutePath()); FileWriter writer = new FileWriter(reportFile); writer.write(report); writer.close(); sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(reportFile)); } catch (IOException e) { // let's hope the report is < 1 MB sendIntent.putExtra(Intent.EXTRA_TEXT, report); } startActivity(sendIntent); } }
From source file:bg.tudle.mtbtimer.ui.MTBMainActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { Intent intent = new Intent(); intent.setAction(Intent.ACTION_SENDTO); intent.setType("text/plain"); switch (item.getItemId()) { case R.id.menu_feedback: intent.putExtra(Intent.EXTRA_TEXT, getString(R.string.send_from_my_android)); intent.putExtra(Intent.EXTRA_SUBJECT, getString(R.string.app_name)); intent.setData(Uri.parse(getString(R.string.mailto_dimitarniknikolov_gmail_com))); break;/*from w w w . jav a 2s. c om*/ case R.id.menu_share: intent.putExtra(Intent.EXTRA_TEXT, getString(R.string.download_apk_link_) + DOWNLOAD_APP_LINK + getString(R.string.send_from_my_android)); intent.putExtra(Intent.EXTRA_SUBJECT, getString(R.string.checkout_mtbtimer_for_android)); intent.setData(Uri.parse("mailto:")); break; case R.id.menu_about: try { PackageManager manager = getPackageManager(); PackageInfo info = manager.getPackageInfo(getPackageName(), 0); String aboutMsg = getString(R.string.versioncode_) + info.versionCode + getString(R.string._versionname_) + info.versionName; AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(R.string.app_name).setMessage(aboutMsg).setNeutralButton(R.string.ok, null).show(); } catch (NameNotFoundException e) { e.printStackTrace(); } return true; default: break; } startActivity(intent); return super.onOptionsItemSelected(item); }
From source file:mohammad.adib.oy.OyUtils.java
public static void sendInvite(Context context) { Intent sendIntent = new Intent(); sendIntent.setAction(Intent.ACTION_SEND); sendIntent.putExtra(Intent.EXTRA_TEXT, "Oy! Wanna fraandship?\nSend me an Oy: " + ParseUser.getCurrentUser().getUsername().toUpperCase()); sendIntent.setType("text/plain"); context.startActivity(sendIntent);/*from w ww .j a va 2 s . c o m*/ }
From source file:edu.stanford.mobisocial.dungbeetle.feed.objects.LinkObj.java
public void handleDirectMessage(Context context, Contact from, JSONObject obj) { String mimeType = obj.optString(MIME_TYPE); Uri uri = Uri.parse(obj.optString(URI)); if (fileAvailable(mimeType, uri)) { Intent i = new Intent(); i.setAction(Intent.ACTION_VIEW); i.addCategory(Intent.CATEGORY_DEFAULT); i.setType(mimeType);//from ww w. j a v a 2 s.c o m i.setData(uri); i.putExtra(Intent.EXTRA_TEXT, uri); PendingIntent contentIntent = PendingIntent.getActivity(context, 0, i, PendingIntent.FLAG_CANCEL_CURRENT); (new PresenceAwareNotify(context)).notify("New content from Musubi", "New Content from Musubi", mimeType + " " + uri, contentIntent); } else { Log.w(TAG, "Received file, failed to handle: " + uri); } }
From source file:com.android.messaging.datamodel.NoConfirmationSmsSendService.java
@Override protected void onHandleIntent(final Intent intent) { if (LogUtil.isLoggable(TAG, LogUtil.VERBOSE)) { LogUtil.v(TAG, "NoConfirmationSmsSendService onHandleIntent"); }//from w ww . ja v a 2s. co m final String action = intent.getAction(); if (!TelephonyManager.ACTION_RESPOND_VIA_MESSAGE.equals(action)) { if (LogUtil.isLoggable(TAG, LogUtil.VERBOSE)) { LogUtil.v(TAG, "NoConfirmationSmsSendService onHandleIntent wrong action: " + action); } return; } final Bundle extras = intent.getExtras(); if (extras == null) { if (LogUtil.isLoggable(TAG, LogUtil.VERBOSE)) { LogUtil.v(TAG, "Called to send SMS but no extras"); } return; } // Get all possible extras from intent final String conversationId = intent.getStringExtra(UIIntents.UI_INTENT_EXTRA_CONVERSATION_ID); final String selfId = intent.getStringExtra(EXTRA_SELF_ID); final boolean requiresMms = intent.getBooleanExtra(UIIntents.UI_INTENT_EXTRA_REQUIRES_MMS, false); final String message = getText(intent, Intent.EXTRA_TEXT); final String subject = getText(intent, Intent.EXTRA_SUBJECT); final int subId = extras.getInt(EXTRA_SUBSCRIPTION, ParticipantData.DEFAULT_SELF_SUB_ID); final Uri intentUri = intent.getData(); final String recipients = intentUri != null ? MmsUtils.getSmsRecipients(intentUri) : null; if (TextUtils.isEmpty(recipients) && TextUtils.isEmpty(conversationId)) { if (LogUtil.isLoggable(TAG, LogUtil.VERBOSE)) { LogUtil.v(TAG, "Both conversationId and recipient(s) cannot be empty"); } return; } if (extras.getBoolean("showUI", false)) { startActivity(new Intent(this, ConversationListActivity.class)); } else { if (TextUtils.isEmpty(message)) { if (LogUtil.isLoggable(TAG, LogUtil.VERBOSE)) { LogUtil.v(TAG, "Message cannot be empty"); } return; } // TODO: it's possible that a long message would require sending it via mms, // but we're not testing for that here and we're sending the message as an sms. if (TextUtils.isEmpty(conversationId)) { InsertNewMessageAction.insertNewMessage(subId, recipients, message, subject); } else { MessageData messageData = null; if (requiresMms) { if (LogUtil.isLoggable(TAG, LogUtil.VERBOSE)) { LogUtil.v(TAG, "Auto-sending MMS message in conversation: " + conversationId); } messageData = MessageData.createDraftMmsMessage(conversationId, selfId, message, subject); } else { if (LogUtil.isLoggable(TAG, LogUtil.VERBOSE)) { LogUtil.v(TAG, "Auto-sending SMS message in conversation: " + conversationId); } messageData = MessageData.createDraftSmsMessage(conversationId, selfId, message); } InsertNewMessageAction.insertNewMessage(messageData); } UpdateMessageNotificationAction.updateMessageNotification(); } }
From source file:com.camera.simplewebcam.push.GcmIntentService.java
@Override protected void onHandleIntent(Intent intent) { Bundle extras = intent.getExtras();//from ww w . ja va 2s.c om GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(this); // The getMessageType() intent parameter must be the intent you received // in your BroadcastReceiver. String messageType = gcm.getMessageType(intent); if (!extras.isEmpty()) { // has effect of unparcelling Bundle /* * Filter messages based on message type. Since it is likely that GCM will be * extended in the future with new message types, just ignore any message types you're * not interested in, or that you don't recognize. */ if (GoogleCloudMessaging.MESSAGE_TYPE_SEND_ERROR.equals(messageType)) { Log.e(TAG, "Send error: " + extras.toString()); } else if (GoogleCloudMessaging.MESSAGE_TYPE_DELETED.equals(messageType)) { Log.e(TAG, "Deleted messages on server: " + extras.toString()); // If it's a regular GCM message, do some work. } else if (GoogleCloudMessaging.MESSAGE_TYPE_MESSAGE.equals(messageType)) { Log.i(TAG, "Completed work @ " + SystemClock.elapsedRealtime()); Log.i(TAG, "Received: " + extras.getString("text")); Intent sendIntent = new Intent(getApplicationContext(), Main.class); sendIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP); sendIntent.setAction(Intent.ACTION_SEND); sendIntent.putExtra(Intent.EXTRA_TEXT, extras.getString("text")); startActivity(sendIntent); } } // Release the wake lock provided by the WakefulBroadcastReceiver. GcmBroadcastReceiver.completeWakefulIntent(intent); }
From source file:com.anjalimacwan.activity.NoteEditActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_note_edit); // Apply theme SharedPreferences pref = getSharedPreferences(getPackageName() + "_preferences", Context.MODE_PRIVATE); String theme = pref.getString("theme", "light-sans"); LinearLayout noteViewEdit = (LinearLayout) findViewById(R.id.noteViewEdit); if (theme.contains("light")) noteViewEdit.setBackgroundColor(ContextCompat.getColor(this, R.color.window_background)); if (theme.contains("dark")) noteViewEdit.setBackgroundColor(ContextCompat.getColor(this, R.color.window_background_dark)); // Set action bar elevation if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) getSupportActionBar().setElevation(getResources().getDimensionPixelSize(R.dimen.action_bar_elevation)); if (!(getSupportFragmentManager().findFragmentById(R.id.noteViewEdit) instanceof NoteEditFragment)) { // Handle intents Intent intent = getIntent();/*from ww w. j a v a2 s . c o m*/ String action = intent.getAction(); String type = intent.getType(); // Intent sent through an external application if (Intent.ACTION_SEND.equals(action) && type != null) { if ("text/plain".equals(type)) { external = intent.getStringExtra(Intent.EXTRA_TEXT); if (external != null) { newNote(); } else { showToast(R.string.loading_external_file); finish(); } } else { showToast(R.string.loading_external_file); finish(); } // Intent sent through Google Now "note to self" } else if ("com.google.android.gm.action.AUTO_SEND".equals(action) && type != null) { if ("text/plain".equals(type)) { external = intent.getStringExtra(Intent.EXTRA_TEXT); if (external != null) { try { // Write note to disk FileOutputStream output = openFileOutput(String.valueOf(System.currentTimeMillis()), Context.MODE_PRIVATE); output.write(external.getBytes()); output.close(); // Show toast notification and finish showToast(R.string.note_saved); finish(); } catch (IOException e) { // Show error message as toast if file fails to save showToast(R.string.failed_to_save); finish(); } } } } else newNote(); } }
From source file:codepath.watsiapp.fragments.DonateShareFragment.java
private void startShareIntent() { Intent shareIntent = new Intent(); shareIntent.setAction(Intent.ACTION_SEND); shareIntent.putExtra(Intent.EXTRA_TEXT, patientProfileUrl); shareIntent.setType("text/plain"); shareIntent.putExtra(Intent.EXTRA_SUBJECT, "Fund Treatment"); startActivity(Intent.createChooser(shareIntent, "Share Story")); }
From source file:com.pureexe.calinoius.environment.camera.fragment.MainFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_main, container, false); dataManager = new DataManager(getActivity()); try {/* w w w. j a v a 2 s .c o m*/ // Use Try catch Exception to avoid force close with CM's Privacy Guard Cursor c = getActivity().getApplication().getContentResolver() .query(ContactsContract.Profile.CONTENT_URI, null, null, null, null); c.moveToFirst(); dataManager.setString("Researcher", c.getString(c.getColumnIndex("display_name"))); } catch (Exception e) { dataManager.setString("Researcher", "Unknown"); } GridView gridview = (GridView) rootView.findViewById(R.id.gridView1); gridview.setAdapter(new HomePageAdapter(getActivity())); gridview.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView<?> parent, View v, int position, long id) { if (position == 0) { Intent beepActivity = new Intent(getActivity(), FragmentDisplayActivity.class); beepActivity.setAction(Intent.ACTION_SEND); beepActivity.putExtra(Intent.EXTRA_TEXT, "UserFragment"); beepActivity.setType("beepActivity"); startActivity(beepActivity); } if (position == 1) { Intent intent = new Intent(getActivity(), EnvironmentCameraActivity.class); startActivity(intent); } if (position == 2) { Intent beepActivity = new Intent(getActivity(), FragmentDisplayActivity.class); beepActivity.setAction(Intent.ACTION_SEND); beepActivity.putExtra(Intent.EXTRA_TEXT, "EXIFreadFragment"); beepActivity.setType("beepActivity"); startActivity(beepActivity); } if (position == 3) { Intent beepActivity = new Intent(getActivity(), FragmentDisplayActivity.class); beepActivity.setAction(Intent.ACTION_SEND); beepActivity.putExtra(Intent.EXTRA_TEXT, "SettingPreferenceFragment"); beepActivity.setType("beepActivity"); startActivity(beepActivity); } if (position == 4) { Intent beepActivity = new Intent(getActivity(), FragmentDisplayActivity.class); beepActivity.setAction(Intent.ACTION_SEND); beepActivity.putExtra(Intent.EXTRA_TEXT, "HelpFragment"); beepActivity.setType("beepActivity"); startActivity(beepActivity); } if (position == 5) { Intent beepActivity = new Intent(getActivity(), FragmentDisplayActivity.class); beepActivity.setAction(Intent.ACTION_SEND); beepActivity.putExtra(Intent.EXTRA_TEXT, "AboutFragment"); beepActivity.setType("beepActivity"); startActivity(beepActivity); } } }); return rootView; }