private void SendNotification (Bundle data) { Intent intent; string type = data.GetString("type"); intent = new Intent (this, typeof(MainActivity)); if(type.Equals(PUSH_INVITE)) { ViewController.getInstance().pushEventId = Convert.ToInt32(data.GetString("eventId")); intent.SetAction(PUSH_INVITE); } else if(type.Equals(PUSH_EVENT_UPDATE)) { ViewController.getInstance().pushEventId = Convert.ToInt32(data.GetString("eventId")); intent.SetAction(PUSH_EVENT_UPDATE); } else if(type.Equals(PUSH_DELETE)) { //nothing else need to be done //MainActivity will refresh the events on start } intent.AddFlags (ActivityFlags.ClearTop); var pendingIntent = PendingIntent.GetActivity (this, 0, intent, PendingIntentFlags.OneShot); var notificationBuilder = new Notification.Builder(this) .SetSmallIcon (Resource.Drawable.pushnotification_icon) .SetContentTitle (data.GetString("title")) .SetContentText (data.GetString ("message")) .SetVibrate(new long[] {600, 600}) .SetAutoCancel (true) .SetContentIntent (pendingIntent); var notificationManager = (NotificationManager)GetSystemService(Context.NotificationService); notificationManager.Notify (notificationId, notificationBuilder.Build()); notificationId++; }
public override void OnReceive (Context context, Intent intent) { var serviceIntent = new Intent (context, typeof (WidgetStartStopService)); serviceIntent.SetAction (intent.Action); serviceIntent.PutExtra (WidgetProvider.TimeEntryIdParameter, intent.GetStringExtra (WidgetProvider.TimeEntryIdParameter)); StartWakefulService (context, serviceIntent); }
public void EnableVoiceSynthesisEngine() { Intent intent = new Intent(); intent.SetAction("com.android.settings.TTS_SETTINGS"); intent.SetFlags(ActivityFlags.NewTask); CurrentActivity.StartActivity(intent); }
public void Stop() { var context = Forms.Context.ApplicationContext; var intent = new Intent(context, typeof(StreamingService)); intent.SetAction(StreamingService.ActionStop); Forms.Context.StartService(intent); }
protected override void OnCreate (Bundle bundle) { base.OnCreate (bundle); var toggle_alarm_operation = new Intent (this, typeof(FindPhoneService)); toggle_alarm_operation.SetAction(FindPhoneService.ACTION_TOGGLE_ALARM); var toggle_alarm_intent = PendingIntent.GetService (this, 0, toggle_alarm_operation, PendingIntentFlags.CancelCurrent); Android.App.Notification.Action alarm_action = new Android.App.Notification.Action (Resource.Drawable.alarm_action_icon, "", toggle_alarm_intent); var cancel_alarm_operation = new Intent (this, typeof(FindPhoneService)); cancel_alarm_operation.SetAction (FindPhoneService.ACTION_CANCEL_ALARM); var cancel_alarm_intent = PendingIntent.GetService (this, 0, cancel_alarm_operation, PendingIntentFlags.CancelCurrent); var title = new SpannableString ("Find My Phone"); title.SetSpan (new RelativeSizeSpan (0.85f), 0, title.Length(), SpanTypes.PointMark); notification = new Notification.Builder (this) .SetContentTitle (title) .SetContentText ("Tap to sound an alarm on phone") .SetSmallIcon (Resource.Drawable.ic_launcher) .SetVibrate (new long[]{ 0, 50 }) .SetDeleteIntent (cancel_alarm_intent) .Extend (new Notification.WearableExtender () .AddAction (alarm_action) .SetContentAction (0) .SetHintHideIcon (true)) .SetLocalOnly (true) .SetPriority ((int)NotificationPriority.Max); ((NotificationManager)GetSystemService (NotificationService)) .Notify (FIND_PHONE_NOTIFICATION_ID, notification.Build ()); Finish (); }
public override void Start() { Bundle hints = new Bundle(); foreach (Symbology symbology in _enabled) { switch (symbology) { case Symbology.UPCE: hints.PutBoolean(DO_UPCE, true); break; case Symbology.EAN8: hints.PutBoolean(DO_EAN8, true); break; case Symbology.EAN13: hints.PutBoolean(DO_EAN13, true); break; case Symbology.Code39: hints.PutBoolean(DO_CODE93, true); break; case Symbology.Code93: hints.PutBoolean(DO_CODE39, true); break; case Symbology.Code128: hints.PutBoolean(DO_CODE128, true); break; case Symbology.Sticky: hints.PutBoolean(DO_STICKY, true); break; case Symbology.UPCA: break; default: break; } } hints.PutString(DO_BROADCAST_TO, RedLaserScanReceiver.BROADCAST_ACTION); Intent i = new Intent(); i.SetAction("com.target.redlasercontainer.SCAN"); i.PutExtras(hints); Log.Info("BarcodeScanning", "broadcast intent with action com.target.redlasercontainter.SCAN sent"); try { _context.SendBroadcast(i); } catch (Exception ex) { Log.Error("BarcodeScanning", ex.Message); } }
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); }
/// <summary> /// Process results from started activities. /// </summary> protected override void OnActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == RECOGNIZER_RESULT && resultCode == RESULT_OK) { var matches = data.GetStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS); var speechText = FindViewById<TextView>(R.Ids.speechText); recognizedText = matches.Get(0); speechText.SetText(recognizedText); var checkIntent = new Intent(); checkIntent.SetAction(TextToSpeech.Engine.ACTION_CHECK_TTS_DATA); StartActivityForResult(checkIntent, SPEECH_RESULT); } if (requestCode == SPEECH_RESULT) { if (resultCode == TextToSpeech.Engine.CHECK_VOICE_DATA_PASS) { textToSpeech = new TextToSpeech(this, this); textToSpeech.SetLanguage(Locale.US); } else { // TTS data not yet loaded, try to install it var ttsLoadIntent = new Intent(); ttsLoadIntent.SetAction(TextToSpeech.Engine.ACTION_INSTALL_TTS_DATA); StartActivity(ttsLoadIntent); } } base.OnActivityResult(requestCode, resultCode, data); }
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); }
private void ButtonOnClick(object sender, EventArgs eventArgs) { Intent = new Intent(); Intent.SetType("image/*"); Intent.SetAction(Intent.ActionGetContent); StartActivityForResult(Intent.CreateChooser(Intent, "Select Picture"), PickImageId); }
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); }
public void InstallAPK_MoreThanAndroid7(Java.IO.File apkFileToInstall) { Android.Content.Intent intent = new Android.Content.Intent(); intent.SetAction(Android.Content.Intent.ActionView); if (string.IsNullOrWhiteSpace(mFileProvider_Authority)) { throw new Exception("mFileProvider_Authority为空值。请使用 SetFileProvider_Authority(string) 方法设置 mFileProvider_Authority 的值。"); } Android.Net.Uri uri = Android.Support.V4.Content.FileProvider.GetUriForFile ( context: mAppActivity.ApplicationContext, authority: mFileProvider_Authority, file: apkFileToInstall ); intent.SetDataAndType(uri, "application/vnd.android.package-archive"); intent.SetFlags(Android.Content.ActivityFlags.NewTask); // SetFlags 一定要在 Add Flags 之前, 否则 Add Flags 会被覆盖 intent.AddFlags(Android.Content.ActivityFlags.GrantReadUriPermission); intent.AddFlags(Android.Content.ActivityFlags.GrantWriteUriPermission); mAppActivity.Application.StartActivity(intent); }
public void Scan() { var intent = new Intent(); Activity current = (Activity)Forms.Context; intent.SetAction(ACTION_SOFTSCANTRIGGER); intent.PutExtra(EXTRA_PARAM, DWAPI_TOGGLE_SCANNING); current.SendBroadcast(intent); }
public Intent getRemoveShortcutIntent(string name, Uri uri) { Intent i = new Intent(); i.PutExtra(Intent.ExtraShortcutIntent, getNoteViewShortcutIntent(name, uri)); i.PutExtra(Intent.ExtraShortcutName, name); i.SetAction("com.android.launcher.action.UNINSTALL_SHORTCUT"); return i; }
private void InstallAPK_Simple(Java.IO.File apkFileToInstall) { Android.Content.Intent intent = new Android.Content.Intent(); intent.SetAction(Android.Content.Intent.ActionView); intent.SetFlags(Android.Content.ActivityFlags.NewTask); intent.SetDataAndType(Android.Net.Uri.FromFile(apkFileToInstall), "application/vnd.android.package-archive"); mAppActivity.Application.StartActivity(intent); }
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); }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); Intent = new Intent(Intent.ActionPick, Android.Provider.MediaStore.Video.Media.ExternalContentUri); Intent.SetAction(Intent.ActionPick); StartActivityForResult(Intent, PickImageId); }
public void ShowImage (string imageURL) { Intent intent = new Intent(); intent.AddFlags (ActivityFlags.NewTask); intent.SetAction(Intent.ActionView); intent.SetDataAndType(Android.Net.Uri.Parse(imageURL), "image/*"); Application.Context.StartActivity(intent); }
public void Play(Uri source) { var context = Forms.Context.ApplicationContext; var intent = new Intent(context, typeof(StreamingService)); intent.SetAction(StreamingService.ActionPlay); intent.PutExtra("source", source.AbsoluteUri); Forms.Context.StartService(intent); }
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); }
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); }
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); }
protected override void OnActivityResult(int req, Result res, Intent data) { if (req == NeedLang) { // we need a new language installed var installTTS = new Intent(); installTTS.SetAction(TextToSpeech.Engine.ActionInstallTtsData); StartActivity(installTTS); } }
public void openGallery() { Toast.MakeText(Xamarin.Forms.Forms.Context, "Select max 20 images", ToastLength.Long).Show(); var imageIntent = new Intent(Intent.ActionPick); imageIntent.SetType("image/*"); imageIntent.PutExtra(Intent.ExtraAllowMultiple, true); imageIntent.SetAction(Intent.ActionGetContent); ((Activity)Xamarin.Forms.Forms.Context).StartActivityForResult( Intent.CreateChooser(imageIntent, "Select photo"), 0); }
//bcast the msg to all actvities private void BroadcastStarted( MyMessage msg) { Intent BroadcastIntent = new Intent(this, typeof(ChatActivity.MsgBroadcasrReceiver)); BroadcastIntent.PutExtra("fromEmail", msg.email); BroadcastIntent.PutExtra("fromName", msg.first_name); BroadcastIntent.PutExtra("message", msg.message); BroadcastIntent.SetAction(ChatActivity.MsgBroadcasrReceiver.MSG_BCAST); BroadcastIntent.AddCategory(Intent.CategoryDefault); SendBroadcast(BroadcastIntent); }
public void SelectImage() { MainActivity androidContext = (MainActivity)Forms.Context; Intent imageIntent = new Intent(); imageIntent.SetType("image/*"); imageIntent.SetAction(Intent.ActionGetContent); androidContext.ConfigureActivityResultCallback(ImageChooserCallback); androidContext.StartActivityForResult(Intent.CreateChooser(imageIntent, "Select photo"), 0); }
/// <summary> /// Click the button and send a message /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void button_Click(object sender, System.EventArgs e) { // Starts the IntentService and connects Intent mServiceIntent = new Intent(this, typeof(BackgroundService)); mServiceIntent.PutExtra(ServiceMessage.JID, messageRecipient); mServiceIntent.PutExtra(ServiceMessage.MESSAGE, message + messageCount); mServiceIntent.SetAction(ServiceAction.SENDMESSAGE.ToString()); StartService(mServiceIntent); button.Text = string.Format("{0} Messages!", messageCount++); }
/// <Docs>The Context in which the receiver is running.</Docs> /// <summary> /// This method is called when the BroadcastReceiver is receiving an Intent /// broadcast. /// </summary> /// <param name="context">Context object.</param> /// <param name="intent">Intent object.</param> public override void OnReceive(Context context, Intent intent) { System.Diagnostics.Debug.WriteLine(string.Format("{0} - {1}", CrossGeofence.Id, "Region State Change Received")); var serviceIntent = new Intent(context, typeof(GeofenceTransitionsIntentService)); serviceIntent.AddFlags(ActivityFlags.IncludeStoppedPackages); serviceIntent.ReplaceExtras(intent.Extras); serviceIntent.SetAction(intent.Action); WakefulBroadcastReceiver.StartWakefulService(context, serviceIntent); this.ResultCode = Result.Ok; }
public override void SetBadge(int count) { var intent = new Intent(); intent.SetAction("com.sonyericsson.home.action.UPDATE_BADGE"); intent.PutExtra("com.sonyericsson.home.intent.extra.badge.PACKAGE_NAME", GetPackageName()); intent.PutExtra("com.sonyericsson.home.intent.extra.badge.ACTIVITY_NAME", GetMainActivityClassName()); intent.PutExtra("com.sonyericsson.home.intent.extra.badge.SHOW_MESSAGE", count > 0); intent.PutExtra("com.sonyericsson.home.intent.extra.badge.MESSAGE", count.ToString()); mContext.SendBroadcast(intent); }
/// <summary> /// On geofence update received fires an intent to be handled by GeofenceTransitionsIntentService /// </summary> /// <param name="context"></param> /// <param name="intent"></param> public override void OnReceive(Context context, Intent intent) { Debug.WriteLine("{0} - {1}", CrossGeofence.Id, "Region State Change Received"); var serviceIntent = new Intent(context, typeof(GeofenceTransitionsIntentService)); serviceIntent.AddFlags(ActivityFlags.IncludeStoppedPackages); serviceIntent.ReplaceExtras(intent.Extras); serviceIntent.SetAction(intent.Action); StartWakefulService(context, serviceIntent); ResultCode = Result.Ok; }
private void InitializeAddPictureButton() { var addPictureButton = FindViewById<Button>(Resource.Id.addPictureButton); addPictureButton.Click += (object sender, EventArgs e) => { var intent = new Intent(); intent.SetType("image/*"); intent.SetAction(Intent.ActionGetContent); StartActivityForResult(Intent.CreateChooser(intent, "Select Picture"), PickImageId); }; }
void OnLearnMoreClick(object sender, EventArgs e) { var intent = new Intent(); // // Use ActionView with an http Data value to launch Android's web browser Activity. // intent.SetAction(Intent.ActionView); intent.SetData(Android.Net.Uri.Parse("http://www.xamarin.com")); StartActivity(intent); }