async void TryHandleOpenedFromNotification(Intent?intent) { try { if (intent?.GetStringExtra("ShinyNotification") is string notificationString) { var notification = JsonConvert.DeserializeObject <Shiny.Notifications.Notification>(notificationString); using var scope = ContainerService.Container.BeginLifetimeScope(); var analyticsService = scope.Resolve <IAnalyticsService>(); var notificationService = scope.Resolve <NotificationService>(); if (notification.Title is string notificationTitle && notification.Message is string notificationMessage && notification.BadgeCount is int badgeCount && badgeCount > 0) { await notificationService.HandleNotification(notificationTitle, notificationMessage, badgeCount).ConfigureAwait(false); } } } catch (ObjectDisposedException) { } }
protected override void OnNewIntent(Intent?intent) { base.OnNewIntent(intent); var action = intent?.Action; if (!string.IsNullOrWhiteSpace(action)) { if (navController == null) { return; } if (Enum.TryParse <TabItemViewModel.TabItemId>(action, out var tabItem)) { var id = tabItem switch { TabItemViewModel.TabItemId.CommunityProxy => Resource.Id.navigation_community_fix, TabItemViewModel.TabItemId.LocalAuth => Resource.Id.navigation_local_auth, TabItemViewModel.TabItemId.ArchiSteamFarmPlus => Resource.Id.navigation_asf_plus, _ => navController.CurrentDestination.Id, }; if (id != navController.CurrentDestination.Id) { navController.Navigate(id); } } } }
public override void OnReceive(Context?context, Intent?intent) { if (intent == null) { return; } var toastId = ToastId.FromIntent(intent); if (toastId == null) { return; } var tcs = hrIntentManager.Value.PopTask(toastId); switch (intent.Action) { case IntentConstants.KTapped: OnTapped(toastId, tcs); break; case IntentConstants.KScheduled: OnScheduled(toastId, intent); break; default: tcs?.TrySetResult(NotificationResult.UserCanceled); break; } }
protected override void OnActivityResult(int requestCode, Result resultCode, Intent?data) { base.OnActivityResult(requestCode, resultCode, data); ActivityResultCallbackRegistry.InvokeCallback(requestCode, resultCode, data); MauiApplication.Current?.Services?.InvokeLifecycleEvents <AndroidLifecycle.OnActivityResult>(del => del(this, requestCode, resultCode, data)); }
public override void OnReceive(Context?context, Intent?intent) { if (intent != null) { bleSubj.OnNext(intent); } }
public override StartCommandResult OnStartCommand(Intent?intent, StartCommandFlags flags, int startId) { CreateNotificationChannel(); StartForeground(NotificationId, CreateNotification()); return(StartCommandResult.Sticky); }
public override void OnReceive(Context?context, Intent?intent) { CultureInfo.CurrentCulture = CultureInfo.GetCultureInfo(Locale.Default.Language); if (SettingsRepository.Settings.Language == AppLanguage.FollowSystem) { LocalizationResourceManager.Current.CurrentCulture = CultureInfo.CurrentCulture; } }
protected override async Task OnReceiveAsync(Context?context, Intent?intent) { if (ActivityRecognitionResult.HasResult(intent) && Process != null) { var result = ActivityRecognitionResult.ExtractResult(intent); await Process(result); } }
protected override void OnActivityResult(int requestCode, Result resultCode, Intent?data) { if (m_activityDelegates.ContainsKey(requestCode)) { m_activityDelegates[requestCode](data, resultCode); } base.OnActivityResult(requestCode, resultCode, data); }
// startup tasks replace this, but this receiver is still used to trigger the wakeup on reboot protected override async Task OnReceiveAsync(Context?context, Intent?intent) { var e = GeofencingEvent.FromIntent(intent); if (e != null && Process != null) { await Process(e); } }
protected override async Task OnReceiveAsync(Context?context, Intent?intent) { if (intent?.Action == EntryIntentAction && ProcessIntent != null) { await ProcessIntent.Invoke(intent).ConfigureAwait(false); context?.SendBroadcast(new Intent(Intent.ActionCloseSystemDialogs)); } }
public override void OnReceive(Context?context, Intent?intent) { switch (intent?.Action) { case BluetoothAdapter.ActionStateChanged: var newState = (State)intent.GetIntExtra(BluetoothAdapter.ExtraState, -1); stateSubj.OnNext(newState); break; } }
protected override void OnStart(Intent?intent) { this.Service .WhenReading() .SubscribeAsync( reading => this.Delegates.RunDelegates( x => x.OnReading(reading) ) ) .DisposedBy(this.DestroyWith); IsStarted = true; }
protected override void OnActivityResult(int requestCode, Result resultCode, Intent?data) { if (requestCode == CAPTURE_PERMISSION_REQUEST_CODE) { _haveCapturePermission = resultCode == Result.Ok; _mediaProjectionPermissionResultData = data; if (_haveCapturePermission) { StartCall(); } } base.OnActivityResult(requestCode, resultCode, data); }
public override void OnReceive(Context?context, Intent?intent) { var pendingResult = this.GoAsync(); this.OnReceiveAsync(context, intent).ContinueWith(x => { if (x.IsFaulted) { ShinyHost .LoggerFactory .CreateLogger <ILogger <ShinyBroadcastReceiver> >() .LogError(x.Exception, "Error in broadcast receiver"); } pendingResult.Finish(); }); }
public override StartCommandResult OnStartCommand(Intent?intent, StartCommandFlags flags, int startId) { var action = intent?.Action ?? AndroidPlatform.ActionServiceStart; switch (action) { case AndroidPlatform.ActionServiceStart: this.Start(intent); break; case AndroidPlatform.ActionServiceStop: this.Stop(); break; } return(StartCommandResult.Sticky); }
protected virtual void Start(Intent?intent) { this.DestroyWith = new CompositeDisposable(); this.Service = this.Resolve <TService>(); this.Delegates = this.ResolveAll <TDelegate>().ToList(); this.Context = this.Resolve <IAndroidContext>(); this.AndroidNotifications = this.Resolve <AndroidNotificationManager>(); if (this.Context.IsMinApiLevel(26)) { this.Service .WhenAnyProperty() .Subscribe(_ => this.SetNotification()) .DisposedBy(this.DestroyWith); } this.OnStart(intent); }
public override void OnReceive(Context?context, Intent?intent) { if (intent?.GetParcelableExtra(UsbManager.ExtraAccessory) is not UsbAccessory extraAccessory) { return; } if (_accessory.Manufacturer != extraAccessory.Manufacturer || _accessory.Model != extraAccessory.Model) { return; } var permissionGranted = intent.GetBooleanExtra(UsbManager.ExtraPermissionGranted, false); _observer.OnNext(permissionGranted); _observer.OnCompleted(); }
/// <summary> /// 当 Android 系统设置语言发生改变时 /// </summary> /// <param name="context"></param> /// <param name="intent"></param> public override void OnReceive(Context?context, Intent?intent) { if (intent == null) { return; } if (intent.Action != Intent.ActionLocaleChanged) { return; } var cultureInfo = GetCultureInfo(); if (cultureInfo == null) { return; } R.ChangeAutoLanguage(cultureInfo); }
public override StartCommandResult OnStartCommand(Intent?intent, [GeneratedEnum] StartCommandFlags flags, int startId) { if (intent != null) { var action = intent.Action; switch (action) { case START: OnStart(); return(StartCommandResult.RedeliverIntent); case STOP: default: StopSelf(); break; } } return(StartCommandResult.NotSticky); }
public override void OnReceive(Context?context, Intent?intent) { if (intent is null) { return; } var extraDevice = intent.GetParcelableExtra(UsbManager.ExtraDevice) as UsbDevice; if (_device.DeviceName != extraDevice?.DeviceName) { return; } var permissionGranted = intent.GetBooleanExtra(UsbManager.ExtraPermissionGranted, false); _observer.OnNext(permissionGranted); _observer.OnCompleted(); }
public async Task TryProcessIntent(Intent?intent) { if (intent == null || !this.delegates.Any()) { return; } if (intent.HasExtra(IntentNotificationKey)) { var notificationString = intent.GetStringExtra(IntentNotificationKey); var notification = this.serializer.Deserialize <Notification>(notificationString); var action = intent.GetStringExtra(IntentActionKey); var text = RemoteInput.GetResultsFromIntent(intent)?.GetString("Result"); var response = new NotificationResponse(notification, action, text); // the notification lives within the intent since it has already been removed from the repo await this.delegates.RunDelegates(x => x.OnEntry(response)); } }
//public const string AlarmIntentAction = ReceiverName + ".ALARM_ACTION"; protected override async Task OnReceiveAsync(Context?context, Intent?intent) { if (intent?.Action?.Equals(EntryIntentAction) ?? false) { await this.Resolve <AndroidNotificationProcessor>().TryProcessIntent(intent); context?.SendBroadcast(new Intent(Intent.ActionCloseSystemDialogs)); //case AlarmIntentAction: // var notificationId = intent.GetIntExtra("NotificationId", 0); // if (notificationId > 0) // { // var repo = this.Resolve<IRepository>(); // var notification = await repo.Get<Notification>(notificationId.ToString()); // notification.ScheduleDate = null; // await this.Resolve<INotificationManager>().Send(notification); // await repo.Remove<Notification>(notificationId.ToString()); // } // break; } }
async void TryHandleOpenedFromNotification(Intent?intent) { try { if (intent?.GetStringExtra("ShinyNotification") is string notificationString) { var notification = JsonConvert.DeserializeObject <Shiny.Notifications.Notification>(notificationString); using var scope = ContainerService.Container.BeginLifetimeScope(); var analyticsService = scope.Resolve <AnalyticsService>(); var notificationService = scope.Resolve <NotificationService>(); await notificationService.HandleReceivedLocalNotification(notification.Title ?? string.Empty, notification.Message ?? string.Empty, notification.BadgeCount ?? 0).ConfigureAwait(false); } } catch (ObjectDisposedException) { } }
protected override void OnCreate(Bundle?savedInstanceState) { base.OnCreate(savedInstanceState); var extras = savedInstanceState ?? Intent !.Extras; // read the values launched = extras !.GetBoolean(launchedExtra, false); actualIntent = extras.GetParcelable(actualIntentExtra) as Intent; guid = extras.GetString(guidExtra); requestCode = extras.GetInt(requestCodeExtra, -1); if (GetIntermediateTask(guid) is IntermediateTask task) { task.OnCreate?.Invoke(actualIntent); } // if this is the first time, lauch the real activity if (!launched) { StartActivityForResult(actualIntent, requestCode); } }
protected override void OnActivityResult(int requestCode, Result resultCode, Intent?data) { base.OnActivityResult(requestCode, resultCode, data); if (requestCode == AddWifiSettingsRequestCode) { if (data != null && data.HasExtra("android.provider.extra.WIFI_NETWORK_RESULT_LIST")) { var extras = data.GetIntegerArrayListExtra("android.provider.extra.WIFI_NETWORK_RESULT_LIST") ?.Select(i => i.IntValue()).ToArray() ?? new int[0]; if (extras.Length > 0) { var ok = extras.Select(GetResultFromCode).All(r => r == Result.Ok); _result.Text = $"Result {ok}"; return; } } _result.Text = $"Result {resultCode == Result.Ok}"; } }
public override void OnReceive(Context?context, Intent?intent) { Console.WriteLine("Bluetooth event received"); if (intent == null) { return; } string action = intent.Action; if (action != BluetoothDevice.ActionFound) { return; } BluetoothDevice bluetoothDevice = (BluetoothDevice)intent.GetParcelableExtra(BluetoothDevice.ExtraDevice); if (bluetoothDevice == null) { return; } string bluetoothDeviceName = bluetoothDevice.Name; string bluetoothDeviceAddress = bluetoothDevice.Address; if (bluetoothDeviceName == null) { return; } if (!SensorsApp.Core.Bluetooth.bluetoothDevices.ContainsKey(bluetoothDeviceAddress)) { SensorsApp.Core.Bluetooth.bluetoothDevices.Add(bluetoothDeviceAddress, bluetoothDeviceName); SensorsApp.Core.Bluetooth.ListChanged(); } }
protected override void OnNewIntent(Intent?intent) { base.OnNewIntent(intent); MauiApplication.Current?.Services?.InvokeLifecycleEvents <AndroidLifecycle.OnNewIntent>(del => del(this, intent)); }
public TResult?Map(Intent?data) { return(data?.GetResult <TResult>()); }
/// <inheritdoc /> public virtual void OnActivityResult(int requestCode, Android.App.Result resultCode, Intent?data) { }