本文整理汇总了C#中Android.Content.Intent.SetType方法的典型用法代码示例。如果您正苦于以下问题:C# Intent.SetType方法的具体用法?C# Intent.SetType怎么用?C# Intent.SetType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Android.Content.Intent
的用法示例。
在下文中一共展示了Intent.SetType方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ComposeEmail
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));
}
示例2: ShowDraft
/// <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);
}
示例3: OnCreate
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);
};
}
示例4: SharePhoto
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"));
}
示例5: OnContextItemSelected
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);
}
示例6: ChoosePictureFromLibraryWithCrop
/// <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);
}
示例7: GetShareIntent
private Intent GetShareIntent()
{
var intent = new Intent(Intent.ActionSend);
intent.SetType("text/plain");
intent.PutExtra(Intent.ExtraText, feedItem.Title + " " + feedItem.Link + " #PlanetXamarin");
return intent;
}
示例8: OnAttachClick
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);
}
示例9: OpenGallery
public static void OpenGallery(Context context)
{
Intent intent = new Intent(Intent.ActionView);
intent.SetType("image/*");
intent.SetFlags(ActivityFlags.NewTask);
context.StartActivity(intent);
}
示例10: ShareShort
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);
}
示例11: btnProfileImage_Clicked
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);
}
示例12: OnCreateView
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;
}
示例13: OnCreateView
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;
}
示例14: SendLog
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();
}
}
示例15: initShareItent
// 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"));
}
}