public void ComposeEmail( IEnumerable<string> to, IEnumerable<string> cc, string subject, string body, bool isHtml, IEnumerable<EmailAttachment> attachments) { // http://stackoverflow.com/questions/2264622/android-multiple-email-attachments-using-intent var emailIntent = new Intent(Intent.ActionSendMultiple); if (to != null) { emailIntent.PutExtra(Intent.ExtraEmail, to.ToArray()); } if (cc != null) { emailIntent.PutExtra(Intent.ExtraCc, cc.ToArray()); } emailIntent.PutExtra(Intent.ExtraSubject, subject ?? string.Empty); body = body ?? string.Empty; if (isHtml) { emailIntent.SetType("text/html"); emailIntent.PutExtra(Intent.ExtraText, Html.FromHtml(body)); } else { emailIntent.SetType("text/plain"); emailIntent.PutExtra(Intent.ExtraText, body); } var attachmentList = attachments as IList<EmailAttachment> ?? attachments.ToList(); if (attachmentList.Any()) { var uris = new List<IParcelable>(); DoOnActivity(activity => { foreach (var file in attachmentList) { var fileWorking = file; File localfile; using (var localFileStream = activity.OpenFileOutput( fileWorking.FileName, FileCreationMode.WorldReadable)) { localfile = activity.GetFileStreamPath(fileWorking.FileName); fileWorking.Content.CopyTo(localFileStream); } localfile.SetReadable(true, false); uris.Add(Uri.FromFile(localfile)); localfile.DeleteOnExit(); // Schedule to delete file when VM quits. } }); emailIntent.PutParcelableArrayListExtra(Intent.ExtraStream, uris); } // fix for GMail App 5.x (File not found / permission denied when using "StartActivity") StartActivityForResult(0, Intent.CreateChooser(emailIntent, string.Empty)); }
/// <summary> /// Shows the draft. /// </summary> /// <param name="subject">The subject.</param> /// <param name="body">The body.</param> /// <param name="html">if set to <c>true</c> [HTML].</param> /// <param name="to">To.</param> /// <param name="cc">The cc.</param> /// <param name="bcc">The BCC.</param> /// <param name="attachments">The attachments.</param> public void ShowDraft(string subject, string body, bool html, string[] to, string[] cc, string[] bcc, IEnumerable<string> attachments = null) { var intent = new Intent(Intent.ActionSend); intent.SetType(html ? "text/html" : "text/plain"); intent.PutExtra(Intent.ExtraEmail, to); intent.PutExtra(Intent.ExtraCc, cc); intent.PutExtra(Intent.ExtraBcc, bcc); intent.PutExtra(Intent.ExtraSubject, subject ?? string.Empty); if (html) { intent.PutExtra(Intent.ExtraText, Android.Text.Html.FromHtml(body)); } else { intent.PutExtra(Intent.ExtraText, body ?? string.Empty); } if (attachments != null) { intent.AddAttachments (attachments); } this.StartActivity(intent); }
protected override void OnCreate (Bundle bundle) { base.OnCreate (bundle); SetContentView (Resource.Layout.Main); _messageDb = new MessageDb(_databasePath); _textViewMessage = FindViewById<TextView> (Resource.Id.editTextMessage); var button = FindViewById<Button> (Resource.Id.buttonSave); button.Click += delegate { Save (); }; button = FindViewById<Button> (Resource.Id.buttonSend); button.Click += delegate { var intent = new Intent(Android.Content.Intent.ActionSend); intent.SetType("text/plain"); intent.PutExtra(Intent.ExtraEmail, new String[] { }); intent.PutExtra(Intent.ExtraSubject, "Zetetic Message Database"); intent.PutExtra(Intent.ExtraText, "Please find a database attached"); string url = MessageDbProvider.CONTENT_URI.ToString() + "message.db"; intent.PutExtra(Intent.ExtraStream, Android.Net.Uri.Parse(url)); StartActivity(intent); }; }
private void SharePhoto() { var share = new Intent(Intent.ActionSend); share.SetType("image/jpeg"); var values = new ContentValues(); values.Put(MediaStore.Images.ImageColumns.Title, "title"); values.Put(MediaStore.Images.ImageColumns.MimeType, "image/jpeg"); Uri uri = ContentResolver.Insert(MediaStore.Images.Media.ExternalContentUri, values); Stream outstream; try { outstream = ContentResolver.OpenOutputStream(uri); finalBitmap.Compress(Bitmap.CompressFormat.Jpeg, 100, outstream); outstream.Close(); } catch (Exception e) { } share.PutExtra(Intent.ExtraStream, uri); share.PutExtra(Intent.ExtraText, "Sharing some images from android!"); StartActivity(Intent.CreateChooser(share, "Share Image")); }
public override bool OnContextItemSelected(IMenuItem item) { switch(item.ItemId) { case Resource.Id.menu_edit_task: SetupEditActionBar(); m_TaskEditText.Text = m_AllTasks[m_EditTaskPosition].Task; FocusMainText(); return true; case Resource.Id.menu_share_task: var intent = new Intent(Intent.ActionSend); intent.SetType("text/plain"); var stringId = m_AllTasks[m_EditTaskPosition].Checked ? Resource.String.share_finished : Resource.String.share_not_finished; var shareMessage = string.Format(Resources.GetString(stringId), m_AllTasks[m_EditTaskPosition].Task); intent.PutExtra(Intent.ExtraText, shareMessage); StartActivity(Intent.CreateChooser(intent, Resources.GetString(Resource.String.share))); return true; } return base.OnContextItemSelected(item); }
/// <summary> /// This call should use some platform capability to "crop" the image to the specified maxPixelDimension /// This is platform specific. WP8 when you set PixelWidth and PixelHeight to maxPixelDimension, it /// creates a crop box on the picture task displayed. /// </summary> public void ChoosePictureFromLibraryWithCrop(int maxPixelDimension, int percentQuality, Action<Stream> pictureAvailable, Action assumeCancelled) { var intent = new Intent(Intent.ActionGetContent); intent.SetType("image/*"); ChoosePictureCommon(MvxIntentRequestCode.PickFromFile, intent, maxPixelDimension, percentQuality, pictureAvailable, assumeCancelled); }
private Intent GetShareIntent() { var intent = new Intent(Intent.ActionSend); intent.SetType("text/plain"); intent.PutExtra(Intent.ExtraText, feedItem.Title + " " + feedItem.Link + " #PlanetXamarin"); return intent; }
private void OnAttachClick(object sender, EventArgs e) { var imageIntent = new Intent(); imageIntent.SetType("image/*"); imageIntent.SetAction(Intent.ActionGetContent); StartActivityForResult(Intent.CreateChooser(imageIntent, "Select a photo"), SelectPhotoId); }
public static void OpenGallery(Context context) { Intent intent = new Intent(Intent.ActionView); intent.SetType("image/*"); intent.SetFlags(ActivityFlags.NewTask); context.StartActivity(intent); }
public void ShareShort(string message) { var shareIntent = new Intent(global::Android.Content.Intent.ActionSend); shareIntent.PutExtra(global::Android.Content.Intent.ExtraText, message ?? string.Empty); shareIntent.SetType("text/plain"); StartActivity(shareIntent); }
void btnProfileImage_Clicked(object sender, EventArgs e) { var imageIntent = new Intent (); imageIntent.SetType ("image/jpeg"); imageIntent.SetAction (Intent.ActionGetContent); StartActivityForResult (Intent.CreateChooser (imageIntent, "Select photo"), 0); }
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { _contentView = inflater.Inflate(Resource.Layout.device_detail, null); _contentView.FindViewById<Button>(Resource.Id.btn_connect).Click += (sender, args) => { var config = new WifiP2pConfig { DeviceAddress = _device.DeviceAddress, Wps = { Setup = WpsInfo.Pbc } }; if (_progressDialog != null && _progressDialog.IsShowing) _progressDialog.Dismiss(); _progressDialog = ProgressDialog.Show(Activity, "Press back to cancel", "Connecting to: " + _device.DeviceAddress, true, true); ((IDeviceActionListener)Activity).Connect(config); }; _contentView.FindViewById<Button>(Resource.Id.btn_disconnect).Click += (sender, args) => ((IDeviceActionListener)Activity).Disconnect(); _contentView.FindViewById<Button>(Resource.Id.btn_start_client).Click += (sender, args) => { var intent = new Intent(Intent.ActionGetContent); intent.SetType("image/*"); StartActivityForResult(intent, ChooseFileResultCode); }; return _contentView; }
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { var rootView = inflater.Inflate(Resource.Layout.FragmentSectionLaunchpad, container, false); var demoCollectionBtn = rootView.FindViewById<Button>(Resource.Id.DemoCollectionButton); // Demonstration of a collection-browsing activity. demoCollectionBtn.Click += delegate { var intent = new Intent(this.Activity, typeof(CollectionDemoActivity)); this.StartActivity(intent); }; var demoListNavBtn = rootView.FindViewById<Button>(Resource.Id.DemoListNavButton); demoListNavBtn.Click += delegate { var intent = new Intent(this.Activity, typeof(ListNavigationActivity)); this.StartActivity(intent); }; var externalActivityBtn = rootView.FindViewById<Button>(Resource.Id.DemoExternalActivityButton); // Demonstration of navigating to external activities. externalActivityBtn.Click += delegate { // Create an intent that asks the user to pick a photo, but using // FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET, ensures that relaunching // the application from the device home screen does not return // to the external activity. var externalActivityIntent = new Intent(Intent.ActionPick); externalActivityIntent.SetType("image/*"); externalActivityIntent.AddFlags(ActivityFlags.ClearWhenTaskReset); this.StartActivity(externalActivityIntent); }; return rootView; }
protected override void SendLog(Log log, Action onSuccess, Action onFail) { if (_settings.DevelopersEmail != null) { var email = new Intent(Intent.ActionSend); email.PutExtra(Intent.ExtraSubject, EMAIL_TITLE); email.PutExtra(Intent.ExtraText, log.Text); email.PutExtra(Intent.ExtraEmail, new[] { _settings.DevelopersEmail }); if (!Directory.Exists(BitBrowserApp.Temp)) Directory.CreateDirectory(BitBrowserApp.Temp); string path = Path.Combine(BitBrowserApp.Temp, "info.xml"); using (var stream = new FileStream(path, FileMode.OpenOrCreate , FileAccess.ReadWrite, FileShare.None)) using (var writer = new StreamWriter(stream)) writer.Write(log.Attachment); email.PutExtra(Intent.ExtraStream, Android.Net.Uri.Parse("file://" + path)); email.SetType("plain/text"); _screen.StartActivityForResult(email , BaseScreen.ReportEmailRequestCode , (resultCode, data) => onSuccess()); } else { if (log.SendReport()) onSuccess(); else onFail(); } }
// http://stackoverflow.com/questions/6827407/how-to-customize-share-intent-in-android/9229654#9229654 private void initShareItent(String type) { bool found = false; Intent share = new Intent(Android.Content.Intent.ActionSend); share.SetType("image/jpeg"); // gets the list of intents that can be loaded. List<ResolveInfo> resInfo = PackageManager.QueryIntentActivities(share, 0).ToList(); if (resInfo.Count > 0) { foreach (ResolveInfo info in resInfo) { if (info.ActivityInfo.PackageName.ToLower().Contains(type) || info.ActivityInfo.Name.ToLower().Contains(type)) { share.PutExtra(Intent.ExtraSubject, "[Corpy] hi"); share.PutExtra(Intent.ExtraText, "Hi " + employee.Firstname); // share.PutExtra(Intent.EXTRA_STREAM, Uri.fromFile(new File(myPath)) ); // class atrribute share.SetPackage(info.ActivityInfo.PackageName); found = true; break; } } if (!found) return; StartActivity(Intent.CreateChooser(share, "Select")); } }
private void ButtonOnClick(object sender, EventArgs eventArgs) { Intent = new Intent(); Intent.SetType("image/*"); Intent.SetAction(Intent.ActionGetContent); StartActivityForResult(Intent.CreateChooser(Intent, "Select Picture"), PickImageId); }
public virtual Task ComposeEmail(IEmailMessage emailMessage) { if (!CanComposeEmail) { throw new FeatureNotAvailableException(); } var intent = new Intent(Intent.ActionSend); intent.PutExtra(Intent.ExtraEmail, emailMessage.To.Select(x => x.Address).ToArray()); intent.PutExtra(Intent.ExtraCc, emailMessage.Cc.Select(x => x.Address).ToArray()); intent.PutExtra(Intent.ExtraBcc, emailMessage.Bcc.Select(x => x.Address).ToArray()); intent.PutExtra(Intent.ExtraTitle, emailMessage.Subject); if (emailMessage.IsHTML) { intent.PutExtra(Intent.ExtraText, Html.FromHtml(emailMessage.Body)); } else { intent.PutExtra(Intent.ExtraText, emailMessage.Body); } intent.SetType("message/rfc822"); intent.StartNewActivity(); return Task.FromResult(true); }
public void ShareText(string text) { var intent = new Intent(Intent.ActionSend); intent.SetType("text/plain"); intent.PutExtra(Intent.ExtraText, text); Forms.Context.StartActivity(Intent.CreateChooser(intent, "Share")); }
public void getBglPath() { var intent = new Intent(Forms.Context,typeof(FilePickerActivity)); intent.PutExtra(FilePickerActivity.ExtraInitialDirectory, "/"); intent.SetType("text/plain"); intent.PutExtra(FilePickerActivity.ExtraMode, (int)FilePickerMode.File); ((Activity)Forms.Context).StartActivityForResult(intent, FilePickerActivity.ResultCodeDirSelected); }
public void List_Click(StoreLink item) { var shareIntent = new Intent(Intent.ActionSend); var text = StaticResources.FormatShareMessage(); shareIntent.PutExtra(Intent.ExtraText, text); shareIntent.SetType("text/plain"); StartActivity(Intent.CreateChooser(shareIntent, Resources.GetString(Resource.String.share))); }
public void ShareText(string text) { Intent sendIntent = new Intent(); sendIntent.SetAction(Intent.ActionSend); sendIntent.PutExtra(Intent.ExtraText, text); sendIntent.SetType("text/plain"); this.StartActivity(sendIntent); }
public void ShareAchievement(string text) { Intent sendIntent = new Intent(); sendIntent.SetAction(Intent.ActionSend); sendIntent.PutExtra(Intent.ExtraText, "Look at this achievement from the ProgramADroid app: " + text); sendIntent.SetType("text/plain"); StartActivity(sendIntent); }
private void ShareOnService(string status, string title = "", string link = "") { var intent = new Intent(global::Android.Content.Intent.ActionSend); intent.PutExtra(global::Android.Content.Intent.ExtraText, String.Format("{0} - {1}", status ?? string.Empty, link ?? string.Empty)); intent.PutExtra(global::Android.Content.Intent.ExtraSubject, title ?? string.Empty); intent.SetType("text/plain"); Forms.Context.StartActivity(intent); }
public static Intent CreateShareForecastIntent(string text) { var shareIntent = new Intent(Intent.ActionSend); shareIntent.AddFlags(ActivityFlags.ClearWhenTaskReset); shareIntent.SetType("text/plain"); shareIntent.PutExtra(Intent.ExtraText, text); return shareIntent; }
public void OnGetPoiDetailShareUrlResult(ShareUrlResult result) { // ����̴���� Intent it = new Intent(Intent.ActionSend); it.PutExtra(Intent.ExtraText, "��������ͨ���ٶȵ�ͼSDK��������һ��λ��: " + currentAddr + " -- " + result.Url); it.SetType("text/plain"); StartActivity(Intent.CreateChooser(it, "���̴������")); }
public void ShareScore(string level, string score) { Intent sendIntent = new Intent(); sendIntent.SetAction(Intent.ActionSend); sendIntent.PutExtra(Intent.ExtraText, "I got " + score + " points on " + level + " in the ProgramADroid app. Can you beat me?"); sendIntent.SetType("text/plain"); StartActivity(sendIntent); }
public void ShowDraft(string subject, string body, bool html, string to) { var intent = new Intent(Intent.ActionSend); intent.SetType(html ? "text/html" : "text/plain"); intent.PutExtra(Intent.ExtraEmail, to); intent.PutExtra(Intent.ExtraSubject, subject ?? string.Empty); intent.PutExtra(Intent.ExtraText, body ?? string.Empty); this.StartActivity(intent); }
public bool Email (string emailAddress) { var intent = new Intent (Intent.ActionSend); intent.SetType ("message/rfc822"); intent.PutExtra (Intent.ExtraEmail, new [] { emailAddress }); Forms.Context.StartActivity (Intent.CreateChooser (intent, "Send email")); return true; }
Intent CreateIntent () { var sendPictureIntent = new Intent (Intent.ActionSend); sendPictureIntent.SetType ("image/*"); var uri = Android.Net.Uri.FromFile (GetFileStreamPath ("monkey.png")); sendPictureIntent.PutExtra (Intent.ExtraStream, uri); return sendPictureIntent; }
private void ShowImageInput() { var intent = new Intent(); intent.SetType("image/*"); intent.SetAction(Intent.ActionGetContent); var mainActivity = (MainActivity) this.Context; mainActivity.ActivityResultCallback = OnActivityResult; mainActivity.StartActivityForResult(Intent.CreateChooser(intent, "Select Picture"), _pickImageId); }