本文整理汇总了C#中Android.Content.Intent.SetData方法的典型用法代码示例。如果您正苦于以下问题:C# Intent.SetData方法的具体用法?C# Intent.SetData怎么用?C# Intent.SetData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Android.Content.Intent
的用法示例。
在下文中一共展示了Intent.SetData方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnCreate
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
// Set our view from the "main" layout resource
SetContentView(Resource.Layout.Main);
// Get our button from the layout resource,
// and attach an event to it
Button button = FindViewById<Button>(Resource.Id.MyButton);
button.Click += delegate {
button.Text = string.Format("{0} clicks!", count++); };
var file = fileFromAsset(this, "test.pdf");
//var uri = Android.Net.Uri.FromFile(new File("file:///android_asset/test.pdf"));
var uri = Android.Net.Uri.Parse(file.AbsolutePath);
var intent = new Intent (this, typeof (MuPDFActivity));
intent.SetFlags (ActivityFlags.NoHistory);
intent.SetAction (Intent.ActionView);
intent.SetData(uri);
this.StartActivity(intent);
}
示例2: OnCreate
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
// Set our view from the "main" layout resource
SetContentView(Resource.Layout.Main);
EditText phoneNumberText = FindViewById<EditText>(Resource.Id.PhoneNumberText);
Button translateButton = FindViewById<Button>(Resource.Id.TranslateButton);
Button callButton = FindViewById<Button>(Resource.Id.CallButton);
Button callHistoryButton = FindViewById<Button>(Resource.Id.CallHistoryButton);
// "Call" を Disable にします
callButton.Enabled = false;
// 番号を変換するコードを追加します。
string translatedNumber = string.Empty;
translateButton.Click += (object sender, EventArgs e) =>
{
// ユーザーのアルファベットの電話番号を電話番号に変換します。
translatedNumber = Core.PhonewordTranslator.ToNumber(phoneNumberText.Text);
if (String.IsNullOrWhiteSpace(translatedNumber))
{
callButton.Text = "Call";
callButton.Enabled = false;
}
else
{
callButton.Text = "Call " + translatedNumber;
callButton.Enabled = true;
}
};
callButton.Click += (object sender, EventArgs e) =>
{
// "Call" ボタンがクリックされたら電話番号へのダイヤルを試みます。
var callDialog = new AlertDialog.Builder(this);
callDialog.SetMessage("Call " + translatedNumber + "?");
callDialog.SetNeutralButton("Call", delegate
{
// 掛けた番号のリストに番号を追加します。
phoneNumbers.Add(translatedNumber);
// Call History ボタンを有効にします。
callHistoryButton.Enabled = true;
// 電話への intent を作成します。
var callIntent = new Intent(Intent.ActionCall);
callIntent.SetData(Android.Net.Uri.Parse("tel:" + translatedNumber));
StartActivity(callIntent);
});
callDialog.SetNegativeButton("Cancel", delegate { });
// アラートダイアログを表示し、ユーザーのレスポンスを待ちます。
callDialog.Show();
};
callHistoryButton.Click += (sender, e) =>
{
var intent = new Intent(this, typeof(CallHistoryActivity));
intent.PutStringArrayListExtra("phone_numbers", phoneNumbers);
StartActivity(intent);
};
}
示例3: OnCreate
protected override void OnCreate (Bundle bundle)
{
base.OnCreate (bundle);
SetContentView (Resource.Layout.RatingDialog);
_cancelButton = FindViewById<Button> (Resource.Id.never_ask);
_rateButton = FindViewById<Button> (Resource.Id.rate_now);
_remindLaterButton = FindViewById<Button> (Resource.Id.rate_later);
var prefs = PreferenceManager.GetDefaultSharedPreferences (this);
_cancelButton.Click += (sender, e) => {
prefs.Edit ().PutBoolean (SettingsScreen.ShouldAskForRating, false).Commit ();
Finish ();
};
_rateButton.Click += (sender, e) => {
prefs.Edit ().PutBoolean (SettingsScreen.ShouldAskForRating, false).Commit ();
var intent = new Intent (Intent.ActionView);
intent.SetData (Android.Net.Uri.Parse ("market://details?id=" + PackageName));
StartActivity (intent);
Finish ();
};
_remindLaterButton.Click += (sender, e) => {
prefs.Edit ().PutInt (SettingsScreen.StartsCount, 0).Commit ();
Finish ();
};
}
示例4: Dial
private void Dial()
{
var book = new Xamarin.Contacts.AddressBook(this);
book.RequestPermission().ContinueWith(t =>
{
if (!t.Result)
{
Console.WriteLine("Permission denied by user or manifest");
return;
}
var validContacts = book.Where(a => a.Phones.Any(b => b.Number.Any())).ToList();
var totalValidContacts = validContacts.Count;
if (totalValidContacts < 1)
{
var alert = new AlertDialog.Builder(this);
alert.SetTitle("No valid Contacts Found");
alert.SetMessage("No valid Contacts Found");
}
var rnd = new Random();
Contact contact = null;
while (contact == null)
{
contact = validContacts.Skip(rnd.Next(0, totalValidContacts)).FirstOrDefault();
}
var urlNumber = Android.Net.Uri.Parse("tel:" + contact.Phones.First().Number);
var intent = new Intent(Intent.ActionCall);
intent.SetData(urlNumber);
this.StartActivity(intent);
}, TaskScheduler.FromCurrentSynchronizationContext());
}
示例5: OnOptionsItemSelected
public override bool OnOptionsItemSelected(IMenuItem item)
{
switch (item.ItemId)
{
case Resource.Id.actionEdit:
Intent editIntent = new Intent(this, typeof(EditActivity));
editIntent.PutExtra("locationid", _location.Id);
StartActivityForResult(editIntent, 1);
return true;
case Resource.Id.actionPhotos:
Intent urlIntent = new Intent(Intent.ActionView);
urlIntent.SetData(Android.Net.Uri.Parse(String.Format("http://www.bing.com/images/search?q={0}", _location.Name))); //$"http://www.bing.com/images/search?q={_location.Name}"));
StartActivity(urlIntent);
return true;
case Resource.Id.actionDirections:
if ((_location.Latitude.HasValue) && (_location.Longitude.HasValue))
{
Intent mapIntent = new Intent(Intent.ActionView,
Android.Net.Uri.Parse(String.Format("geo:{0},{1}", _location.Latitude, _location.Longitude)));//$"geo:{_location.Latitude},{_location.Longitude}"));
StartActivity(mapIntent);
}
return true;
default:
return base.OnOptionsItemSelected(item);
}
}
示例6: OnActivityResult
ImageView _imageView; // create variable to grab the imagview
#endregion Fields
#region Methods
protected override void OnActivityResult(int requestCode, Result resultCode, Intent data)
{
base.OnActivityResult(requestCode, resultCode, data); // base is the same thing as super
// Make it available in the gallery
Intent mediaScanIntent = new Intent(Intent.ActionMediaScannerScanFile);//scan a file and add it to media database
Android.Net.Uri contentUri = Android.Net.Uri.FromFile(App._file); //gets the image file
mediaScanIntent.SetData(contentUri); // put image file into media database
SendBroadcast(mediaScanIntent); //
// Display in ImageView. We will resize the bitmap to fit the display.
// Loading the full sized image will consume to much memory
// and cause the application to crash.
int height = Resources.DisplayMetrics.HeightPixels;
int width = _imageView.Height;
App.bitmap = App._file.Path.LoadAndResizeBitmap(width, height);
if (App.bitmap != null)
{
_imageView.SetImageBitmap(App.bitmap); //set the bitmap to the image view
App.bitmap = null;
}
// Dispose of the Java side bitmap.
GC.Collect();
}
示例7: Call
/// <summary>
/// REQUIRES android.permission.CALL_PHONE
/// </summary>
void Call(int number)
{
String uri = "tel:" + number.ToString();
Intent intent = new Intent(Intent.ActionCall);
intent.SetData(Android.Net.Uri.Parse(uri));
StartActivity(intent);
}
示例8: OnActivityResult
protected override void OnActivityResult(int requestCode, Result resultCode, Intent data)
{
base.OnActivityResult(requestCode, resultCode, data);
// Make it available in the gallery
Intent mediaScanIntent = new Intent(Intent.ActionMediaScannerScanFile);
Uri contentUri = Uri.FromFile(App._file);
mediaScanIntent.SetData(contentUri);
SendBroadcast(mediaScanIntent);
// Display in ImageView. We will resize the bitmap to fit the display
// Loading the full sized image will consume to much memory
// and cause the application to crash.
int height = Resources.DisplayMetrics.HeightPixels;
int width = iv1.Height ;
App.bitmap = App._file.Path.LoadAndResizeBitmap (width, height);
if (App.bitmap != null) {
iv1.SetImageBitmap (App.bitmap);
App.bitmap = null;
}
if ((requestCode == PickImageId) && (resultCode == Result.Ok))
{
Uri uri = data.Data;
iv1.SetImageURI(uri);
}
// Dispose of the Java side bitmap.
GC.Collect();
}
示例9: Show
public void Show()
{
Intent intent = new Intent(Intent.ActionView);
intent.SetData(Uri.Parse("market://details?id=" + Application.Context.PackageName));
intent.SetFlags(ActivityFlags.NewTask);
Application.Context.StartActivity(intent);
}
示例10: AddEvent
public void AddEvent(string name, DateTime startTime, DateTime endTime)
{
Intent intent = new Intent(Intent.ActionInsert);
intent.SetData(Android.Provider.CalendarContract.Events.ContentUri);
// Add Event Details
intent.PutExtra(Android.Provider.CalendarContract.ExtraEventBeginTime, DateTimeJavaDate(startTime));
intent.PutExtra(Android.Provider.CalendarContract.ExtraEventEndTime, DateTimeJavaDate(endTime));
intent.PutExtra(Android.Provider.CalendarContract.EventsColumns.AllDay, false);
// intent.PutExtra(Android.Provider.CalendarContract.EventsColumns.EventLocation, ""); TODO: event location
intent.PutExtra(Android.Provider.CalendarContract.EventsColumns.Description, "UTS:HELPS Workshop");
intent.PutExtra(Android.Provider.CalendarContract.EventsColumns.Title, name);
// open "Add to calendar" screen
Forms.Context.StartActivity(intent);
// TODO: add event directly
// https://github.com/xamarin/monodroid-samples/blob/master/CalendarDemo/EventListActivity.cs
//
// ContentValues eventValues = new ContentValues ();
// eventValues.Put (CalendarContract.Events.InterfaceConsts.CalendarId, ?? ?);
// eventValues.Put (CalendarContract.Events.InterfaceConsts.Title, "Test Event");
// eventValues.Put (CalendarContract.Events.InterfaceConsts.Description, "This is an event created from Mono for Android");
// eventValues.Put (CalendarContract.Events.InterfaceConsts.Dtstart, GetDateTimeMS (2011, 12, 15, 10, 0));
// eventValues.Put (CalendarContract.Events.InterfaceConsts.Dtend, GetDateTimeMS (2011, 12, 15, 11, 0));
//
// eventValues.Put(CalendarContract.Events.InterfaceConsts.EventTimezone, "UTC");
// eventValues.Put(CalendarContract.Events.InterfaceConsts.EventEndTimezone, "UTC");
//
// var uri = ContentResolver.Insert (CalendarContract.Events.ContentUri, eventValues);
// Console.WriteLine ("Uri for new event: {0}", uri);
}
示例11: OnCreate
protected override void OnCreate(Bundle bundle)
{
base.OnCreate (bundle);
// Set our view from the "main" layout resource.
SetContentView (Resource.Layout.Main);
// Get our UI controls from the loaded layout:
EditText phoneNumberText = FindViewById<EditText>(Resource.Id.PhoneNumberText);
Button translateButton = FindViewById<Button>(Resource.Id.TranslateButton);
Button callButton = FindViewById<Button>(Resource.Id.CallButton);
Button callHistoryButton = FindViewById<Button> (Resource.Id.CallHistoryButton);
// Disable the "Call" button.
callButton.Enabled = false;
// Add code to translate number.
string translatedNumber = string.Empty;
translateButton.Click += (object sender, EventArgs e) => {
// Translate user's alphanumeric phone number to numeric.
translatedNumber = Core.PhonewordTranslator.ToNumber(phoneNumberText.Text);
if (String.IsNullOrWhiteSpace(translatedNumber)) {
callButton.Text = "Call";
callButton.Enabled = false;
} else {
callButton.Text = "Call " + translatedNumber;
callButton.Enabled = true;
}
};
callButton.Click += (object sender, EventArgs e) => {
// On "Call" button click, try to dial phone number.
var callDialog = new AlertDialog.Builder(this);
callDialog.SetMessage("Call " + translatedNumber + "?");
callDialog.SetNeutralButton("Call", delegate {
// Add dialed number to list of called numbers.
phoneNumbers.Add(translatedNumber);
// Enable the Call History button.
callHistoryButton.Enabled = true;
// Create intent to dial phone.
var callIntent = new Intent(Intent.ActionCall);
callIntent.SetData(Android.Net.Uri.Parse("tel:" + translatedNumber));
StartActivity(callIntent);
});
callDialog.SetNegativeButton("Cancel", delegate {});
// Show the alert dialog to the user and wait for response.
callDialog.Show();
};
callHistoryButton.Click += (sender, e) => {
var intent = new Intent(this, typeof(CallHistoryActivity));
intent.PutStringArrayListExtra("phone_numbers", phoneNumbers);
StartActivity(intent);
};
}
示例12: OnSourceCodeClick
public void OnSourceCodeClick(object sender, System.EventArgs e)
{
Intent i = new Intent(Intent.ActionView);
i.SetData(Uri.Parse(GetString(Resource.String.sources_link)));
StartActivity(i);
}
示例13: OnWebCheckoutButtonClicked
// Launch the device browser so the user can complete the checkout.
private void OnWebCheckoutButtonClicked(object sender, EventArgs e)
{
var intent = new Intent(Intent.ActionView);
intent.AddFlags(ActivityFlags.NewTask | ActivityFlags.ClearTask);
intent.SetData(Android.Net.Uri.Parse(SampleApplication.Checkout.WebUrl));
try
{
intent.SetPackage("com.android.chrome");
StartActivity(intent);
}
catch (Exception)
{
try
{
// Chrome could not be opened, attempt to us other launcher
intent.SetPackage(null);
StartActivity(intent);
}
catch (Exception)
{
OnError(GetString(Resource.String.checkout_error));
}
}
}
示例14: Show
public void Show()
{
Intent intent = new Intent(Intent.ActionView);
intent.SetData(Android.Net.Uri.Parse(Uri.OriginalString));
intent.SetFlags(ActivityFlags.NewTask);
Application.Context.StartActivity(intent);
}
示例15: introVidBtn_Click
void introVidBtn_Click(object sender, EventArgs e)
{
string videoUrl = "https://openlabdata.blob.core.windows.net/videotuts/pacingIntro.mp4";
Intent i = new Intent(Intent.ActionView);
i.SetData(Android.Net.Uri.Parse(videoUrl));
StartActivity(i);
}