本文整理汇总了C#中Android.Content.Intent类的典型用法代码示例。如果您正苦于以下问题:C# Intent类的具体用法?C# Intent怎么用?C# Intent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Intent类属于Android.Content命名空间,在下文中一共展示了Intent类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: CriarChamada
public void CriarChamada(Activity activity)
{
isRecording = !isRecording;
if (isRecording)
{
// Cria o INTENT
var voiceIntent = new Intent(RecognizerIntent.ActionRecognizeSpeech);
voiceIntent.PutExtra(RecognizerIntent.ExtraLanguageModel, RecognizerIntent.LanguageModelFreeForm);
// Abre um modal com uma mensagem de voz
voiceIntent.PutExtra(RecognizerIntent.ExtraPrompt, "Diga o nome da pessoa");
// Se passar de 5.5s considera que não há mensagem falada
voiceIntent.PutExtra(RecognizerIntent.ExtraSpeechInputCompleteSilenceLengthMillis, 5500);
voiceIntent.PutExtra(RecognizerIntent.ExtraSpeechInputPossiblyCompleteSilenceLengthMillis, 1500);
voiceIntent.PutExtra(RecognizerIntent.ExtraSpeechInputMinimumLengthMillis, 15000);
voiceIntent.PutExtra(RecognizerIntent.ExtraMaxResults, 1);
// Para chamadas em outras líguas
// voiceIntent.PutExtra(RecognizerIntent.ExtraLanguage, Java.Util.Locale.German);
// if you wish it to recognise the default Locale language and German
// if you do use another locale, regional dialects may not be recognised very well
voiceIntent.PutExtra(RecognizerIntent.ExtraLanguage, Java.Util.Locale.Default);
activity.StartActivityForResult(voiceIntent, Constants.VOICE);
}
}
开发者ID:Studyxnet,项目名称:BuscaPorVoz,代码行数:27,代码来源:SpeechPage.cs
示例2: StartLocationService
public static Task StartLocationService()
{
if (_isRunning)
return Task.FromResult(true);
_isRunning = true;
// Starting a service like this is blocking, so we want to do it on a background thread
return Task.Run(() =>
{
// Start our main service
Log.Debug("App", "Calling StartService");
Android.App.Application.Context.StartService(new Intent(Android.App.Application.Context,
typeof (GeolocationService)));
// bind our service (Android goes and finds the running service by type, and puts a reference
// on the binder to that service)
// The Intent tells the OS where to find our Service (the Context) and the Type of Service
// we're looking for (LocationService)
var locationServiceIntent = new Intent(Android.App.Application.Context, typeof (GeolocationService));
Log.Debug("App", "Calling service binding");
// Finally, we can bind to the Service using our Intent and the ServiceConnection we
// created in a previous step.
Android.App.Application.Context.BindService(locationServiceIntent, LocationServiceConnection,
Bind.AutoCreate);
});
}
开发者ID:Azure-Samples,项目名称:MyDriving,代码行数:26,代码来源:GeolocationHelper.cs
示例3: RecordNotificationReceived
public void RecordNotificationReceived(Intent message)
{
var id = message.GetStringExtra(PlatformAccess.BuddyPushKey);
if (!String.IsNullOrEmpty(id)) {
PlatformAccess.Current.OnNotificationReceived(id);
}
}
开发者ID:nickatbuddy,项目名称:Buddy-DotNET-SDK,代码行数:7,代码来源:AndroidPlatformAccess.cs
示例4: ImageChooserCallback
private void ImageChooserCallback(int requestCode, Result resultCode, Intent intent)
{
if (resultCode == Result.Ok)
{
if (ImageSelected != null)
{
Android.Net.Uri uri = intent.Data;
if (ImageSelected != null)
{
ImageSource imageSource = ImageSource.FromStream(() => Forms.Context.ContentResolver.OpenInputStream(uri));
ImageSelected.Invoke(this, new ImageSourceEventArgs(imageSource));
string doc_id = "";
using (var c1 = Forms.Context.ContentResolver.Query (uri, null, null, null, null)) {
c1.MoveToFirst ();
string document_id = c1.GetString (0);
doc_id = document_id.Substring (document_id.LastIndexOf (":") + 1);
}
string selection = Android.Provider.MediaStore.Images.Media.InterfaceConsts.Id + " =? ";
var cursor = Forms.Context.ContentResolver.Query (MediaStore.Images.Media.ExternalContentUri, null, selection, new string[] {doc_id}, null);
var colIndex = cursor.GetColumnIndex(Android.Provider.MediaStore.Images.Media.InterfaceConsts.Data);
cursor.MoveToFirst();
App.imagePath = cursor.GetString (colIndex);
cursor.Close ();
}
}
}
}
开发者ID:ctsxamarintraining,项目名称:cts451792,代码行数:30,代码来源:GalleryImageService_Android.cs
示例5: OnCreateView
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
// Use this to return your custom view for this Fragment
var view = inflater.Inflate(Resource.Layout.HeaderFragmentLayout, container, false);
var homeBtn = view.FindViewById<ImageView>(Resource.Id.HeaderLogo);
var overlayBtn = view.FindViewById<ImageView>(Resource.Id.HeaderOverlay);
var animIn = AnimationUtils.LoadAnimation(Activity.BaseContext, Resource.Animation.Overlay_animIn);
homeBtn.Click += delegate
{
if (!(Activity is MainActivity))
{
var i = new Intent(Activity, typeof(MainActivity));
i.AddFlags(ActivityFlags.NewTask | ActivityFlags.ClearTop);
Activity.StartActivity(i);
}
};
overlayBtn.Click += delegate
{
overlay.View.StartAnimation(animIn);
overlay.Initialize();
overlay.View.Visibility = ViewStates.Visible;
};
return view;
}
开发者ID:JMHornberg,项目名称:PJ6000-Hovedprosjekt,代码行数:27,代码来源:HeaderFragment.cs
示例6: 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++); };
Button button1 = FindViewById<Button>(Resource.Id.button1);
TextView textview = FindViewById<TextView>(Resource.Id.textView1);
button1.Click += delegate { textview.Text = string.Format("{0} hello zzb!!", count); };
Button btnPhone = FindViewById<Button>(Resource.Id.btnPhone);
btnPhone.Click += delegate { };
btnPhone.Click += BtnPhone_Click;
Button btnToSec = FindViewById<Button>(Resource.Id.btnToSec);
btnToSec.Click += delegate {
Intent intent = new Intent(this, typeof(SecondActivity));
StartActivity(intent);
};
}
开发者ID:DavidZhang1976,项目名称:Learning,代码行数:28,代码来源:MainActivity.cs
示例7: OnActivityResult
/// <inheritdoc/>
public override void OnActivityResult(int requestCode, int resultCode, Intent data)
{
ZTnTrace.Trace(MethodBase.GetCurrentMethod());
switch (requestCode)
{
case AddNewAccount:
switch (resultCode)
{
case -1:
var battleTag = data.GetStringExtra("battleTag");
var host = data.GetStringExtra("host");
D3Context.Instance.DbAccounts.Insert(battleTag, host);
IListAdapter careerAdapter = new SimpleCursorAdapter(Activity, Android.Resource.Layout.SimpleListItem2, cursor, accountsFromColumns, accountsToId);
Activity.FindViewById<ListView>(Resource.Id.AccountsListView)
.Adapter = careerAdapter;
Toast.MakeText(Activity, "Account added", ToastLength.Short)
.Show();
break;
}
break;
}
base.OnActivityResult(requestCode, resultCode, data);
}
开发者ID:djtms,项目名称:D3-Android-by-ZTn,代码行数:29,代码来源:CareersListFragment.cs
示例8: OnCreate
protected override void OnCreate (Bundle savedInstanceState)
{
base.OnCreate (savedInstanceState);
// Set our view from the "main" layout resource
SetContentView (Resource.Layout.Main);
//League league = new League ();
Spinner chooseTeamSpinner = FindViewById<Spinner> (Resource.Id.chooseTeamSpinner);
chooseTeamSpinner.ItemSelected += new EventHandler<AdapterView.ItemSelectedEventArgs> (chooseTeamSpinner_ItemSelected);
var adapter = ArrayAdapter.CreateFromResource (
this, Resource.Array.teams_array, Android.Resource.Layout.SimpleSpinnerItem);
adapter.SetDropDownViewResource (Android.Resource.Layout.SimpleSpinnerDropDownItem);
chooseTeamSpinner.Adapter = adapter;
// Get our button from the layout resource,
// and attach an event to it
Button beginSeasonButton = FindViewById<Button> (Resource.Id.beginSeasonButton);
beginSeasonButton.Click += (sender, e) =>
{
var intent = new Intent(this, typeof(SeasonActivity));
intent.PutExtra("userTeam", userTeam);
StartActivity(intent);
};
}
开发者ID:jonesguy14,项目名称:SportSim,代码行数:26,代码来源:MainActivity.cs
示例9: ShowDetails
private void ShowDetails(int playId)
{
_currentPlayId = playId;
if (_isDualPane)
{
// We can display everything in-place with fragments.
// Have the list highlight this item and show the data.
ListView.SetItemChecked(playId, true);
// Check what fragment is shown, replace if needed.
var details = FragmentManager.FindFragmentById(Resource.Id.details) as DetailsFragment;
if (details == null || details.ShownPlayId != playId)
{
// Make new fragment to show this selection.
details = DetailsFragment.NewInstance(playId);
// Execute a transaction, replacing any existing
// fragment with this one inside the frame.
var ft = FragmentManager.BeginTransaction();
ft.Replace(Resource.Id.details, details);
ft.SetTransition(FragmentTransit.FragmentFade);
ft.Commit();
}
}
else
{
// Otherwise we need to launch a new activity to display
// the dialog fragment with selected text.
var intent = new Intent();
intent.SetClass(Activity, typeof(DetailsActivity));
intent.PutExtra("current_play_id", playId);
StartActivity(intent);
}
}
开发者ID:BratislavDimitrov,项目名称:monodroid-samples,代码行数:35,代码来源:TitlesFragment.cs
示例10: ButtonOnClick
private void ButtonOnClick(object sender, EventArgs eventArgs)
{
Intent = new Intent();
Intent.SetType("image/*");
Intent.SetAction(Intent.ActionGetContent);
StartActivityForResult(Intent.CreateChooser(Intent, "Select Picture"), PickImageId);
}
开发者ID:eduardoguilarducci,项目名称:recipes,代码行数:7,代码来源:Activity1.cs
示例11: OnCreate
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
// Set our view from the "main" layout resource
SetContentView (Resource.Layout.Main);
comicListView = FindViewById<ListView>(Resource.Id.ComicList);
comicListView.ChoiceMode = ChoiceMode.Multiple;
comicListView.FastScrollEnabled = true;
data = new ComicList (new CSVParser (Assets.Open ("Data/titles.csv")));
// wire up task click handler
if(comicListView != null) {
comicListView.ItemClick += (object sender, AdapterView.ItemClickEventArgs e) =>
{
// Starting to think I should just serialize this
var comicDetails = new Intent (this, typeof (ComicDetailsActivity));
comicDetails.PutExtra("ComicName", data[e.Position].Name);
comicDetails.PutExtra("ComicDescription", data[e.Position].Description);
comicDetails.PutExtra("ComicPublisher", data[e.Position].Publisher);
comicDetails.PutExtra("ComicDate", data[e.Position].Date);
comicDetails.PutExtra("ID", data[e.Position].ID);
comicDetails.PutExtra("Favourite", data.IsFavourite(e.Position));
comicDetails.PutExtra("OtherComics", data.GetPublisherCount(data[e.Position].Publisher) - 1);
StartActivity (comicDetails);
};
}
}
开发者ID:Aciho,项目名称:DevTest-Xamarin,代码行数:30,代码来源:MainActivity.cs
示例12: Buy_Click
void Buy_Click(object sender, EventArgs e)
{
var intent = new Intent (this, typeof(FinalDialog));
intent.PutExtra ("Extra_Link", _VideoLink);
StartActivity(intent);
}
开发者ID:GeniusAtamans,项目名称:VideoBuyApp,代码行数:7,代码来源:PreviewBuyActivity.cs
示例13: InitMediaSession
internal void InitMediaSession(string packageName, MediaServiceBinder binder)
{
try
{
if (mediaSessionCompat == null)
{
Intent nIntent = new Intent(applicationContext, typeof(MediaPlayer));
PendingIntent pIntent = PendingIntent.GetActivity(applicationContext, 0, nIntent, 0);
RemoteComponentName = new ComponentName(packageName, new RemoteControlBroadcastReceiver().ComponentName);
mediaSessionCompat = new MediaSessionCompat(applicationContext, "XamarinStreamingAudio", RemoteComponentName, pIntent);
mediaControllerCompat = new MediaControllerCompat(applicationContext, mediaSessionCompat.SessionToken);
NotificationManager = new MediaNotificationManagerImplementation(applicationContext, CurrentSession.SessionToken, _serviceType);
}
mediaSessionCompat.Active = true;
mediaSessionCompat.SetCallback(binder.GetMediaPlayerService<MediaServiceBase>().AlternateRemoteCallback ?? new MediaSessionCallback(this));
mediaSessionCompat.SetFlags(MediaSessionCompat.FlagHandlesMediaButtons | MediaSessionCompat.FlagHandlesTransportControls);
_packageName = packageName;
_binder = binder;
}
catch (Exception ex)
{
Console.WriteLine(ex);
}
}
开发者ID:martijn00,项目名称:XamarinMediaManager,代码行数:25,代码来源:MediaSessionManager.cs
示例14: AddEventToCalAction
public AddEventToCalAction(Context context, Intent intent, int drawable, string url)
{
Drawable = drawable;
Context = context;
Intent = intent;
Url = url;
}
开发者ID:mukhtiarlander,项目名称:git_demo_torit,代码行数:7,代码来源:AddEventToCalAction.cs
示例15: DidEnterRegion
public void DidEnterRegion(AltBeaconOrg.BoundBeacon.Region region)
{
// In this example, this class sends a notification to the user whenever a Beacon
// matching a Region (defined above) are first seen.
Log.Debug(TAG, "did enter region.");
if (!haveDetectedBeaconsSinceBoot)
{
Log.Debug(TAG, "auto launching MonitoringActivity");
// The very first time since boot that we detect an beacon, we launch the
// MainActivity
var intent = new Intent(this, typeof(MainActivity));
intent.SetFlags(ActivityFlags.NewTask);
// Important: make sure to add android:launchMode="singleInstance" in the manifest
// to keep multiple copies of this activity from getting created if the user has
// already manually launched the app.
this.StartActivity(intent);
haveDetectedBeaconsSinceBoot = true;
}
else
{
if (mainActivity != null) {
Log.Debug(TAG, "I see a beacon again");
}
else
{
// If we have already seen beacons before, but the monitoring activity is not in
// the foreground, we send a notification to the user on subsequent detections.
Log.Debug(TAG, "Sending notification.");
SendNotification();
}
}
}
开发者ID:Denn1992,项目名称:Android-AltBeacon-Library,代码行数:33,代码来源:BeaconReferenceApplication.cs
示例16: OnReceive
public override void OnReceive(Context context, Intent intent)
{
Android.Util.Log.Info("MonoGame", intent.Action.ToString());
if(intent.Action == Intent.ActionScreenOff)
{
ScreenReceiver.ScreenLocked = true;
MediaPlayer.IsMuted = true;
}
else if(intent.Action == Intent.ActionScreenOn)
{
// If the user turns the screen on just after it has automatically turned off,
// the keyguard will not have had time to activate and the ActionUserPreset intent
// will not be broadcast. We need to check if the lock is currently active
// and if not re-enable the game related functions.
// http://stackoverflow.com/questions/4260794/how-to-tell-if-device-is-sleeping
KeyguardManager keyguard = (KeyguardManager)context.GetSystemService(Context.KeyguardService);
if (!keyguard.InKeyguardRestrictedInputMode())
{
ScreenReceiver.ScreenLocked = false;
MediaPlayer.IsMuted = false;
}
}
else if(intent.Action == Intent.ActionUserPresent)
{
// This intent is broadcast when the user unlocks the phone
ScreenReceiver.ScreenLocked = false;
MediaPlayer.IsMuted = false;
}
}
开发者ID:Boerlam001,项目名称:MonoGame,代码行数:29,代码来源:ScreenReciever.cs
示例17: OnActivityResult
protected override void OnActivityResult(int requestCode, Result resultCode, Intent data)
{
if (requestCode == 111 && resultCode == Result.Ok) {
Console.WriteLine (data.Data);
}
base.OnActivityResult (requestCode, resultCode, data);
}
开发者ID:Grawl,项目名称:hubbl,代码行数:7,代码来源:SongsPickingActivity.cs
示例18: PushPresenter
public void PushPresenter(object presenter)
{
object oldPresenter = application.Presenter;
if(presenter != oldPresenter)
{
application.Presenter = presenter;
Intent i = null;
if(presenter is SearchResultsPresenter)
{
i = new Intent(application.CurrentActivity, typeof(SearchResultsView));
}
else if(presenter is PropertyPresenter)
{
i = new Intent(application.CurrentActivity, typeof(PropertyView));
}
else if(presenter is FavouritesPresenter)
{
i = new Intent(application.CurrentActivity, typeof(FavouritesView));
}
if(i != null)
application.CurrentActivity.StartActivity(i);
}
}
开发者ID:rolfbjarne,项目名称:PropertyCross,代码行数:25,代码来源:NavigationService.cs
示例19: OnHandleIntent
protected override void OnHandleIntent (Intent intent)
{
google_api_client.BlockingConnect (TIME_OUT_MS, TimeUnit.Milliseconds);
Android.Net.Uri dataItemUri = intent.Data;
if (!google_api_client.IsConnected) {
Log.Error (TAG, "Failed to update data item " + dataItemUri +
" because client is disconnected from Google Play Services");
return;
}
var dataItemResult = WearableClass.DataApi.GetDataItem (
google_api_client, dataItemUri).Await ().JavaCast<IDataApiDataItemResult> ();
var putDataMapRequest = PutDataMapRequest.CreateFromDataMapItem (
DataMapItem.FromDataItem (dataItemResult.DataItem));
var dataMap = putDataMapRequest.DataMap;
//update quiz status variables
int questionIndex = intent.GetIntExtra (EXTRA_QUESTION_INDEX, -1);
bool chosenAnswerCorrect = intent.GetBooleanExtra (EXTRA_QUESTION_CORRECT, false);
dataMap.PutInt (Constants.QUESTION_INDEX, questionIndex);
dataMap.PutBoolean (Constants.CHOSEN_ANSWER_CORRECT, chosenAnswerCorrect);
dataMap.PutBoolean (Constants.QUESTION_WAS_ANSWERED, true);
PutDataRequest request = putDataMapRequest.AsPutDataRequest ();
WearableClass.DataApi.PutDataItem (google_api_client, request).Await ();
//remove this question notification
((NotificationManager)GetSystemService (NotificationService)).Cancel (questionIndex);
google_api_client.Disconnect ();
}
开发者ID:WalterVale,项目名称:monodroid-samples,代码行数:29,代码来源:UpdateQuestionService.cs
示例20: OnCreate
protected override void OnCreate(Bundle bundle)
{
base.OnCreate (bundle);
// Create your application here
SetContentView (Resource.Layout.Login);
EditText txtIPAddress = (EditText)FindViewById (Resource.Id.txtIPAddress);
txtIPAddress.Text = this.GetPreference ("preference_q16_address");
Button btnOk = (Button)FindViewById (Resource.Id.btnOk);
btnOk.Click += (sender, e) =>
{
this.SetPreference("preference_q16_address", txtIPAddress.Text);
var main = new Intent(this, typeof(MainActivity));
main.PutExtra("address", txtIPAddress.Text);
main.PutExtra("demo", false);
StartActivity(main);
};
Button btnDemo = (Button)FindViewById (Resource.Id.btnDemo);
btnDemo.Click += (sender, e) =>
{
var main = new Intent(this, typeof(MainActivity));
main.PutExtra("address", "demo");
main.PutExtra("demo", true);
StartActivity(main);
};
}
开发者ID:GeorgeWieggers,项目名称:QuMixDroid_xamarin,代码行数:27,代码来源:LoginActivity.cs
注:本文中的Android.Content.Intent类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论