protected override void OnCreate(Bundle savedInstanceState) { TabLayoutResource = Resource.Layout.Tabbar; ToolbarResource = Resource.Layout.Toolbar; base.OnCreate(savedInstanceState); Xamarin.Essentials.Platform.Init(this, savedInstanceState); global::Xamarin.Forms.Forms.Init(this, savedInstanceState); IServiceCollection container = new ServiceCollection(); container.AddXamarin(); container.AddSingleton <App>(); container.AddSingleton <IStatusBarService>(new StatusBarService(Window)); container.AddSingleton <ISoundService>(new SoundService(this)); var mediaService = new MediaService(); container.AddSingleton <IMediaService>(mediaService); var provider = container.BuildServiceProvider(); var intentFilter = new IntentFilter(); intentFilter.AddAction("com.android.music.metachanged"); intentFilter.AddAction("com.android.music.playstatechanged"); intentFilter.AddAction("com.android.music.playbackcomplete"); intentFilter.AddAction("com.android.music.queuechanged"); RegisterReceiver(mediaService, intentFilter); var app = provider.GetService <App>(); LoadApplication(app); }
/// <summary> /// Default constructor /// </summary> public BGattCallback() { Log.Debug(TAG, "Creating callback for LE Bluetooth Devices"); // Init lists notifyChars = new List <string>(); deviceDetails = new Dictionary <string, string>(); // Creating read timeout timer readTimer = new System.Timers.Timer(BluetoothConstants.LE_TIMEOUT); readTimer.AutoReset = true; // Setting the last change to be the minimum value lastChange = new DateTime(); lastChange = DateTime.MinValue; // Setting up the Receivers detailReceiver = new SensorReadingBroadcastReceiver(); IntentFilter fil = new IntentFilter(); fil.AddAction(AppUtil.SENSOR_READING_UPDATE_ACTION); fil.Priority = 100; Android.App.Application.Context.RegisterReceiver(detailReceiver, fil); updateReceiver = new SensorStateBroadcastReceiver(); fil = new IntentFilter(); fil.AddAction(AppUtil.SENSOR_CONNECT_ACTION); fil.AddAction(AppUtil.SENSOR_DISCONNECT_ACTION); fil.AddAction(AppUtil.SENSOR_REMOVED_ACTION); fil.Priority = 100; Android.App.Application.Context.RegisterReceiver(updateReceiver, fil); }
public void StartNotification() { if (started) { return; } notificationColor = ResourceHelper.GetThemeColor(Service.ApplicationContext, Resource.Attribute.colorPrimary, Color.DarkGray); metadata = controller.Metadata; playbackState = controller.PlaybackState; var notification = CreateNotification(); if (notification == null) { return; } started = true; controller.RegisterCallback(callback); var filter = new IntentFilter(); filter.AddAction(ActionNext); filter.AddAction(ActionPause); filter.AddAction(ActionPlay); filter.AddAction(ActionPrevious); filter.AddAction(ActionStopCasting); Service.RegisterReceiver(this, filter); Service.StartForeground(NotificationId, notification); }
protected override void OnCreate(Bundle savedInstanceState) { TabLayoutResource = Resource.Layout.Tabbar; ToolbarResource = Resource.Layout.Toolbar; base.OnCreate(savedInstanceState); Instance = this; FreshMvvm.FreshIOC.Container.Register <IPortSIPEvents, PortSipService>(); FreshMvvm.FreshIOC.Container.Register <IService, PortSipService>(); IntentFilter filter = new IntentFilter(); filter.AddAction(PortSipService.REGISTER_CHANGE_ACTION); filter.AddAction(PortSipService.CALL_CHANGE_ACTION); filter.AddAction(PortSipService.PRESENCE_CHANGE_ACTION); RegisterReceiver(receiver, filter); Intent onLineIntent = new Intent(this, typeof(PortSipService)); StartService(onLineIntent); Rg.Plugins.Popup.Popup.Init(this, savedInstanceState); Xamarin.Essentials.Platform.Init(this, savedInstanceState); global::Xamarin.Forms.Forms.Init(this, savedInstanceState); LoadApplication(new App()); }
public void Start() { try { broadcastReceiver = new CustomBroadcastReceiver(); CurrentActivity = (Activity)Forms.Context; IntentFilter filter = new IntentFilter(); filter.AddAction(BluetoothDevice.ActionFound); filter.AddAction(BluetoothAdapter.ActionDiscoveryStarted); filter.AddAction(BluetoothAdapter.ActionDiscoveryFinished); CurrentActivity.RegisterReceiver(broadcastReceiver, filter); /* * broadcastReceiver.DeviceDiscoveryStarted += (o, t) => * { * DoDeviceDiscoveryStarted(); * }; * broadcastReceiver.DeviceDiscovered += (o, t) => * { * DoOnDeviceDiscovered(t.Device); * }; */ started = true; } catch (Exception) { } }
public void Start() { if (!listening) { var synchronizationContext = Dependency.Resolve <ISynchronizationContext>(); synchronizationContext.Send(() => { lock (listeningLock) { if (!listening) { var intentFilter = new IntentFilter(/*Intent.ActionBatteryChanged*/); intentFilter.AddAction(Intent.ActionBatteryLow); intentFilter.AddAction(Intent.ActionBatteryOkay); intentFilter.AddAction(Intent.ActionPowerConnected); intentFilter.AddAction(Intent.ActionPowerDisconnected); intentFilter.AddAction(Intent.ActionBatteryChanged); //var context = Application.Context; var context = Dependency.Resolve <Activity>(); receiver = new PowerConnectionReceiver(this); /*batteryStatusIntent = */ context.RegisterReceiver(receiver, intentFilter); listening = true; } } }); } }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.activity_main); Android.Support.V7.Widget.Toolbar toolbar = FindViewById <Android.Support.V7.Widget.Toolbar>(Resource.Id.toolbar); SetSupportActionBar(toolbar); // button = FindViewById <Button>(Resource.Id.buttonSearchDevice); //кнопка поиск устройства textview = FindViewById <TextView>(Resource.Id.textView1); //текстовое поле (вывод сообщений) textview.Text = "Начать поиск!"; button.Click += Button_Click; toStart = true; Filter = new IntentFilter(); Filter.AddAction(BluetoothAdapter.ActionStateChanged); Filter.AddAction(BluetoothAdapter.ActionDiscoveryStarted); Filter.AddAction(BluetoothAdapter.ActionDiscoveryFinished); Filter.AddAction(BluetoothDevice.ActionFound); RegisterReceiver(receiver, Filter); if (!ba.IsEnabled) { Intent enableBtIntent = new Intent(BluetoothAdapter.ActionRequestEnable); this.StartActivityForResult(enableBtIntent, RequestEnableBt); } //FloatingActionButton fab = FindViewById<FloatingActionButton>(Resource.Id.fab); //fab.Click += FabOnClick; }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.main); locationButton = (Button)FindViewById(Resource.Id.location_button); locationButton.Click += delegate { StartActivity(new Intent(BaseContext, typeof (LocationActivity))); }; // Set up custom preference screen style button Button customPreferencesButton = (Button)FindViewById(Resource.Id.push_custom_preferences_button); customPreferencesButton.Click += delegate { StartActivity(new Intent(BaseContext, typeof (CustomPreferencesActivity))); }; // Set up android built-in preference screen style button Button preferencesButton = (Button)FindViewById(Resource.Id.push_preferences_button); preferencesButton.Click += delegate { StartActivity(new Intent(BaseContext, typeof (PreferencesActivity))); }; boundServiceFilter = new IntentFilter(); boundServiceFilter.AddAction(UALocationManager.GetLocationIntentAction(UALocationManager.ActionSuffixLocationServiceBound)); boundServiceFilter.AddAction(UALocationManager.GetLocationIntentAction(UALocationManager.ActionSuffixLocationServiceUnbound)); apidUpdateFilter = new IntentFilter(); apidUpdateFilter.AddAction(UAirship.PackageName + IntentReceiver.APID_UPDATED_ACTION_SUFFIX); }
protected override void OnCreate(Bundle savedInstanceState) { _design.ApplyTheme(); base.OnCreate(savedInstanceState); if (PreferenceManager.GetDefaultSharedPreferences(this).GetBoolean( GetString(Resource.String.ViewDatabaseSecure_key), true)) { Window.SetFlags(WindowManagerFlags.Secure, WindowManagerFlags.Secure); } _ioc = App.Kp2a.CurrentDb?.Ioc; if (Intent.GetBooleanExtra(NoLockCheck, false)) { return; } _intentReceiver = new LockCloseActivityBroadcastReceiver(this); IntentFilter filter = new IntentFilter(); filter.AddAction(Intents.DatabaseLocked); filter.AddAction(Intent.ActionScreenOff); RegisterReceiver(_intentReceiver, filter); }
protected override void OnResume() { base.OnResume(); ValidateServiceReceiver(); var intentFilter = new IntentFilter(FileBoundService.ActionFeedback) { Priority = (int)IntentFilterPriority.HighPriority }; intentFilter.AddAction(FileBoundService.ActionZipLogFiles); intentFilter.AddAction(FileBoundService.ActionExportLog); RegisterReceiver(_serviceReceiver, intentFilter); ServiceConnectionDispose(); _serviceConnection = new ServiceConnection(this); var serviceIntent = AndroidUtil.CreateExplicitFromImplicitIntent(this, new Intent(FileBoundService.ActionZipLogFiles)); BindService(serviceIntent, _serviceConnection, Bind.AutoCreate); try { StartFileService(); } catch (Exception ex) { ShowProgressbar(false); ShowError(ex, Resource.String.InternalError); } }
protected override void OnCreate(Bundle bundle) { TabLayoutResource = Resource.Layout.Tabbar; ToolbarResource = Resource.Layout.Toolbar; MobileBarcodeScanner.Initialize(Application); base.OnCreate(bundle); Plugin.CurrentActivity.CrossCurrentActivity.Current.Init(this, bundle); global::Xamarin.Forms.Forms.Init(this, bundle); //lazer BarcodeReader broadcastReceiver var lazerrec = new BarCodeReader(); IntentFilter filter = new IntentFilter(); filter.AddAction("com.zebra.sdl.action.STARTED"); filter.AddAction("com.zebra.sdl.action.RELEASED"); filter.AddAction("com.zebra.sdl.action.SCAN_COMPLETE"); RegisterReceiver(lazerrec, filter); //Intent camera = new Intent(MediaStore.ActionImageCapture); //StartActivityForResult(camera, 1); LoadApplication(new App()); Task.Run(async() => { await GrantPermissions(); }); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(R.Layout.local_service_broadcaster); // This is where we print the data we get back. TextView callbackData = (TextView)FindViewById(R.Id.callback); // Put in some initial text. callbackData.Text = ("No broadcast received yet"); // We use this to send broadcasts within our local process. mLocalBroadcastManager = LocalBroadcastManager.GetInstance(this); // We are going to watch for interesting local broadcasts. IntentFilter filter = new IntentFilter(); filter.AddAction(ACTION_STARTED); filter.AddAction(ACTION_UPDATE); filter.AddAction(ACTION_STOPPED); mReceiver = new MyBroadcastReceiver(callbackData); mLocalBroadcastManager.RegisterReceiver(mReceiver, filter); // Watch for button clicks. Button button = (Button)FindViewById(R.Id.start); button.Click += (o,e) => StartService(new Intent(this, typeof(LocalService))); button = (Button)FindViewById(R.Id.stop); button.Click += (o,e) => StopService(new Intent(this, typeof(LocalService))); }
protected override void OnCreate(Bundle savedInstanceState) { TabLayoutResource = Resource.Layout.Tabbar; ToolbarResource = Resource.Layout.Toolbar; mRfidManager = RfidManager.InitInstance(this); //RFID Code MyDataReceiver = new MyBroadcastReceiver(); filter = new IntentFilter(); filter.AddAction(GeneralString.IntentRFIDSERVICECONNECTED); filter.AddAction(GeneralString.IntentRFIDSERVICETAGDATA); //filter.AddAction(GeneralString.IntentRFIDSERVICEEVENT); //filter.AddAction(GeneralString.IntentFWUpdateErrorMessage); //filter.AddAction(GeneralString.IntentFWUpdatePercent); //filter.AddAction(GeneralString.IntentFWUpdateFinish); filter.AddAction(GeneralString.IntentGUNAttached); filter.AddAction(GeneralString.IntentGUNAttached); //filter.AddAction(GeneralString.IntentGUNPower); //RegisterReceiver(MyDataReceiver, filter); //End RFID Code //mRfidManager.Release(); base.OnCreate(savedInstanceState); Xamarin.Essentials.Platform.Init(this, savedInstanceState); Rg.Plugins.Popup.Popup.Init(this, savedInstanceState); global::Xamarin.Forms.Forms.Init(this, savedInstanceState); Context context = Android.App.Application.Context; LoadApplication(new App(context)); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.main); locationButton = (Button)FindViewById(Resource.Id.location_button); locationButton.Click += delegate { StartActivity(new Intent(BaseContext, typeof(LocationActivity))); }; // Set up custom preference screen style button Button customPreferencesButton = (Button)FindViewById(Resource.Id.push_custom_preferences_button); customPreferencesButton.Click += delegate { StartActivity(new Intent(BaseContext, typeof(CustomPreferencesActivity))); }; // Set up android built-in preference screen style button Button preferencesButton = (Button)FindViewById(Resource.Id.push_preferences_button); preferencesButton.Click += delegate { StartActivity(new Intent(BaseContext, typeof(PreferencesActivity))); }; boundServiceFilter = new IntentFilter(); boundServiceFilter.AddAction(UALocationManager.GetLocationIntentAction(UALocationManager.ActionSuffixLocationServiceBound)); boundServiceFilter.AddAction(UALocationManager.GetLocationIntentAction(UALocationManager.ActionSuffixLocationServiceUnbound)); apidUpdateFilter = new IntentFilter(); apidUpdateFilter.AddAction(UAirship.PackageName + IntentReceiver.APID_UPDATED_ACTION_SUFFIX); }
void Init() { _filter = new IntentFilter(); _filter.AddAction("android.bluetooth.adapter.action.STATE_CHANGED"); _filter.AddAction("android.location.PROVIDERS_CHANGED"); AppDomain.CurrentDomain.UnhandledException += LogUtils.OnUnhandledException; AndroidEnvironment.UnhandledExceptionRaiser += OnUnhandledAndroidException; #if APPCENTER AppCenter.Start( Configuration.Conf.APPCENTER_DIAGNOSTICS_TOKEN, typeof(Analytics), typeof(Crashes)); #endif DroidDependencyInjectionConfig.Init(); Xamarin.Essentials.Platform.Init(this); Current.Init(this); LocalesService.Initialize(); new MigrationService().Migrate(); _permissionsBroadcastReceiver = new PermissionsBroadcastReceiver(); _flightModeBroadcastReceiver = new FlightModeHandlerBroadcastReceiver(); _backgroundNotificationBroadcastReceiver = new BackgroundNotificationBroadcastReceiver(); LogUtils.SendAllLogs(); if (PlayServicesVersionUtils.PlayServicesVersionNumberIsLargeEnough(PackageManager)) { BackgroundFetchScheduler.ScheduleBackgroundFetch(); } }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(R.Layouts.local_service_broadcaster); // This is where we print the data we get back. TextView callbackData = (TextView)FindViewById(R.Ids.callback); // Put in some initial text. callbackData.SetText("No broadcast received yet"); // We use this to send broadcasts within our local process. mLocalBroadcastManager = LocalBroadcastManager.GetInstance(this); // We are going to watch for interesting local broadcasts. IntentFilter filter = new IntentFilter(); filter.AddAction(ACTION_STARTED); filter.AddAction(ACTION_UPDATE); filter.AddAction(ACTION_STOPPED); mReceiver = new MyBroadcastReceiver(callbackData); mLocalBroadcastManager.RegisterReceiver(mReceiver, filter); // Watch for button clicks. Button button = (Button)FindViewById(R.Ids.start); button.Click += (o, e) => StartService(new Intent(this, typeof(LocalService))); button = (Button)FindViewById(R.Ids.stop); button.Click += (o, e) => StopService(new Intent(this, typeof(LocalService))); }
public static void Initialize(Context ctx) { P2PManager.ctx = ctx; if (intentFilter == null) { intentFilter = new IntentFilter(); intentFilter.AddAction(WifiP2pManager.WifiP2pStateChangedAction); intentFilter.AddAction(WifiP2pManager.WifiP2pPeersChangedAction); intentFilter.AddAction(WifiP2pManager.WifiP2pConnectionChangedAction); intentFilter.AddAction(WifiP2pManager.WifiP2pThisDeviceChangedAction); } if (manager == null) { manager = (WifiP2pManager)ctx.GetSystemService(Context.WifiP2pService); channel = manager.Initialize(ctx, ctx.MainLooper, null); } if (receiver == null) { receiver = new WiFiDirectBroadcastReceiver(manager, channel); } ctx.RegisterReceiver(receiver, intentFilter); }
public AlarmService() { //base(TAG); matcher = new IntentFilter(); matcher.AddAction(CREATE); matcher.AddAction(CANCEL); matcher.AddAction(UPDATE); }
public BeaconReceiver(Context context) { androidContext = context; intentFilter = new IntentFilter(); intentFilter.AddAction(BeaconService.BeaconDetectedReceiverAction); intentFilter.AddAction(BeaconService.BeaconExpirationReceiverAction); androidContext.RegisterReceiver(this, intentFilter); }
public static IntentFilter GetIntentFilter() { IntentFilter filter = new IntentFilter(); filter.AddAction(ACTION_COMPLETED); filter.AddAction(ACTION_ERROR); return(filter); }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); Console.WriteLine("XamFace: OnCreate Called"); displayManager = (DisplayManager)GetSystemService(Context.DisplayService); displayManager.RegisterDisplayListener(this, null); // Set our view from the "main" layout resource SetContentView(Resource.Layout.Main); time = FindViewById <TextView> (Resource.Id.textTime); date = FindViewById <TextView> (Resource.Id.textDate); day = FindViewById <TextView> (Resource.Id.textDay); xamarinLogo = FindViewById <ImageView> (Resource.Id.xamarinLogo); wheelSeconds = FindViewById <ProgressWheel> (Resource.Id.wheelSeconds); wheelMinutes = FindViewById <ProgressWheel> (Resource.Id.wheelMinutes); wheelHours = FindViewById <ProgressWheel> (Resource.Id.wheelHours); wheelMinutes.Alpha = 0.6f; wheelHours.Alpha = 0.3f; wheelHours.ProgressMax = 24; wheelSeconds.RimColor = Android.Graphics.Color.Transparent; wheelHours.RimColor = Android.Graphics.Color.Transparent; wheelMinutes.RimColor = Android.Graphics.Color.Transparent; RunOnUiThread(UpdateUI); var filter = new IntentFilter(); filter.AddAction(Intent.ActionTimeTick); filter.AddAction(Intent.ActionTimeChanged); filter.AddAction(Intent.ActionTimezoneChanged); timeBroadcastReceiver = new SimpleBroadcastReceiver(); timeBroadcastReceiver.Receive = () => { Console.WriteLine("Time Changed"); RunOnUiThread(UpdateUI); }; RegisterReceiver(timeBroadcastReceiver, filter); batteryBroadcastReceiver = new SimpleBroadcastReceiver(); batteryBroadcastReceiver.Receive = () => { Console.WriteLine("Battery Changed"); RunOnUiThread(UpdateUI); }; RegisterReceiver(batteryBroadcastReceiver, new IntentFilter(Intent.ActionBatteryChanged)); timerSeconds = new Timer(new TimerCallback(state => { RunOnUiThread(() => UpdateUITime(null)); }), null, TimeSpan.FromSeconds(1), TimeSpan.FromSeconds(1)); }
#pragma warning disable CS0809 // 过时成员重写未过时成员 public override void Register() #pragma warning restore CS0809 // 过时成员重写未过时成员 { var filter = new IntentFilter(); filter.AddAction(WifiManager.NetworkIdsChangedAction); filter.AddAction(ConnectivityManager.ConnectivityAction); context.RegisterReceiver(_receiver, filter); }
/** * regist screen state broadcast */ private void registerListener() { IntentFilter filter = new IntentFilter(); filter.AddAction(Intent.ActionScreenOn); filter.AddAction(Intent.ActionScreenOff); filter.AddAction(Intent.ActionUserPresent); _mContext.RegisterReceiver(_mScreenReceiver, filter); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.activity_main); mWearableActionDrawer = FindViewById <WearableActionDrawerView>(Resource.Id.bottom_action_drawer); mWearableActionDrawer.SetOnMenuItemClickListener(this); mWearableActionDrawer.PeekOnScrollDownEnabled = true; mWearableNavigationDrawer = FindViewById <WearableNavigationDrawerView>(Resource.Id.top_nav_drawer); mWearableNavigationDrawer.AddOnItemSelectedListener(this); mWearableNavigationDrawer.PeekOnScrollDownEnabled = true; mNavDrawerAdapter = new NavDrawerAdapter(this); mWearableNavigationDrawer.SetAdapter(mNavDrawerAdapter); mBroadcastReceiver = new LocalBroadcastReceiver(); mBroadcastReceiver.BroadcastReceived += (context, intent) => { if (WearableDataListenerService.ACTION_SHOWSTORELISTING.Equals(intent?.Action)) { var intentAndroid = new Intent(Intent.ActionView) .AddCategory(Intent.CategoryBrowsable) .SetData(WearableHelper.PlayStoreURI); RemoteIntent.StartRemoteActivity(this, intentAndroid, new ConfirmationResultReceiver(this)); } else if (WearableDataListenerService.ACTION_OPENONPHONE.Equals(intent?.Action)) { bool success = (bool)intent?.GetBooleanExtra(WearableDataListenerService.EXTRA_SUCCESS, false); new ConfirmationOverlay() .SetType(success ? ConfirmationOverlay.OpenOnPhoneAnimation : ConfirmationOverlay.FailureAnimation) .ShowOn(this); } }; var filter = new IntentFilter(); filter.AddAction(WearableDataListenerService.ACTION_SHOWSTORELISTING); filter.AddAction(WearableDataListenerService.ACTION_OPENONPHONE); LocalBroadcastManager.GetInstance(this).RegisterReceiver(mBroadcastReceiver, filter); // Create your application here Fragment fragment = FragmentManager.FindFragmentById(Resource.Id.fragment_container); // Check if fragment exists if (fragment == null) { fragment = new WeatherNowFragment(); // Navigate to WeatherNowFragment FragmentManager.BeginTransaction() .Replace(Resource.Id.fragment_container, fragment, "home") .Commit(); } }
protected override void OnCreate (Bundle bundle) { base.OnCreate (bundle); Console.WriteLine ("XamFace: OnCreate Called"); displayManager = (DisplayManager)GetSystemService (Context.DisplayService); displayManager.RegisterDisplayListener (this, null); // Set our view from the "main" layout resource SetContentView (Resource.Layout.Main); time = FindViewById<TextView> (Resource.Id.textTime); date = FindViewById<TextView> (Resource.Id.textDate); day = FindViewById<TextView> (Resource.Id.textDay); xamarinLogo = FindViewById<ImageView> (Resource.Id.xamarinLogo); wheelSeconds = FindViewById<ProgressWheel> (Resource.Id.wheelSeconds); wheelMinutes = FindViewById<ProgressWheel> (Resource.Id.wheelMinutes); wheelHours = FindViewById<ProgressWheel> (Resource.Id.wheelHours); wheelMinutes.Alpha = 0.6f; wheelHours.Alpha = 0.3f; wheelHours.ProgressMax = 24; wheelSeconds.RimColor = Android.Graphics.Color.Transparent; wheelHours.RimColor = Android.Graphics.Color.Transparent; wheelMinutes.RimColor = Android.Graphics.Color.Transparent; RunOnUiThread (UpdateUI); var filter = new IntentFilter (); filter.AddAction (Intent.ActionTimeTick); filter.AddAction (Intent.ActionTimeChanged); filter.AddAction (Intent.ActionTimezoneChanged); timeBroadcastReceiver = new SimpleBroadcastReceiver (); timeBroadcastReceiver.Receive = () => { Console.WriteLine ("Time Changed"); RunOnUiThread (UpdateUI); }; RegisterReceiver (timeBroadcastReceiver, filter); batteryBroadcastReceiver = new SimpleBroadcastReceiver (); batteryBroadcastReceiver.Receive = () => { Console.WriteLine ("Battery Changed"); RunOnUiThread (UpdateUI); }; RegisterReceiver (batteryBroadcastReceiver, new IntentFilter (Intent.ActionBatteryChanged)); timerSeconds = new Timer (new TimerCallback (state => { RunOnUiThread (() => UpdateUITime (null)); }), null, TimeSpan.FromSeconds (1), TimeSpan.FromSeconds (1)); }
public static ServiceReceiver Create(Context context) { var receiver = new ServiceReceiver(); var filter = new IntentFilter(); filter.AddAction(Message.Prefs); filter.AddAction(Message.Req); context.RegisterReceiver(receiver, filter); return(receiver); }
protected override void OnResume() { base.OnResume(); var f = new IntentFilter(); f.AddAction(BluetoothDevice.ActionFound); f.AddAction(BluetoothDevice.ActionUuid); f.AddAction(BluetoothAdapter.ActionDiscoveryFinished); RegisterReceiver(_receiver, f); }
/// <summary> /// 注册 开屏 关屏 广播 /// </summary> /// <param name="context"></param> public void RegisterKeep(Context context) { IntentFilter filter = new IntentFilter(); filter.AddAction(Intent.ActionScreenOn); filter.AddAction(Intent.ActionScreenOff); mKeepAliveReceiver = new KeepAliveReceiver(); context.RegisterReceiver(mKeepAliveReceiver, filter); }
private static IntentFilter MakeGattUpdateIntentFilter() { IntentFilter intentFilter = new IntentFilter(); intentFilter.AddAction(BluetoothLeService.ACTION_GATT_CONNECTED); intentFilter.AddAction(BluetoothLeService.ACTION_GATT_DISCONNECTED); intentFilter.AddAction(BluetoothLeService.ACTION_GATT_SERVICES_DISCOVERED); intentFilter.AddAction(BluetoothLeService.ACTION_DATA_AVAILABLE); return(intentFilter); }
private void RegisterReceivers() { using (IntentFilter intentFilter = new IntentFilter()) { screenOnOffReceiver = new ScreenOnOffReceiver(); intentFilter.AddAction(Intent.ActionScreenOff); intentFilter.AddAction(Intent.ActionScreenOn); RegisterReceiver(screenOnOffReceiver, intentFilter); } }
public override void OnCreate() { base.OnCreate(); // initialize the current activity plugin here as well as in the main activity // since this service may be created by iteself without a main activity (e.g., // on boot or on OS restart of the service). we want the plugin to have be // initialized regardless of how the app comes to be created. CrossCurrentActivity.Current.Init(Application); SensusContext.Current = new AndroidSensusContext { Platform = Platform.Android, MainThreadSynchronizer = new MainConcurrent(), SymmetricEncryption = new SymmetricEncryption(SensusServiceHelper.ENCRYPTION_KEY), CallbackScheduler = new AndroidCallbackScheduler(this), Notifier = new AndroidNotifier(), PowerConnectionChangeListener = new AndroidPowerConnectionChangeListener() }; // promote this service to a foreground service as soon as possible. we use a foreground service for several // reasons. it's honest and transparent. it lets us work effectively with the android 8.0 restrictions on // background services. we can run forever without being killed. we receive background location updates, etc. (SensusContext.Current.Notifier as AndroidNotifier).UpdateForegroundServiceNotificationBuilder(); StartForeground(AndroidNotifier.FOREGROUND_SERVICE_NOTIFICATION_ID, (SensusContext.Current.Notifier as AndroidNotifier).BuildForegroundServiceNotification()); // https://developer.android.com/reference/android/content/Intent#ACTION_POWER_CONNECTED // This is intended for applications that wish to register specifically to this notification. Unlike ACTION_BATTERY_CHANGED, // applications will be woken for this and so do not have to stay active to receive this notification. This action can be // used to implement actions that wait until power is available to trigger. // // We use the same receiver for both the connected and disconnected intents. _powerBroadcastReceiver = new AndroidPowerConnectionChangeBroadcastReceiver(); IntentFilter powerConnectFilter = new IntentFilter(); powerConnectFilter.AddAction(Intent.ActionPowerConnected); powerConnectFilter.AddAction(Intent.ActionPowerDisconnected); powerConnectFilter.AddCategory(Intent.CategoryDefault); RegisterReceiver(_powerBroadcastReceiver, powerConnectFilter); // must come after context initialization. also, it is here -- below StartForeground -- because it can // take a while to complete and we don't want to run afoul of the short timing requirements on calling // StartForeground. SensusServiceHelper.Initialize(() => new AndroidSensusServiceHelper()); AndroidSensusServiceHelper serviceHelper = SensusServiceHelper.Get() as AndroidSensusServiceHelper; // we might have failed to create the service helper. it's also happened that the service is created // after the service helper is disposed. if (serviceHelper == null) { Stop(); } }
public static void Register(Context context) { IntentFilter filter = new IntentFilter(); filter.AddAction(ACTION_CLASS_MODE); filter.AddAction(ACTION_POWER_SAVING); filter.AddAction(ACTION_KILL_APP); filter.AddAction(ACTION_MIGRATION_KILL_APP); filter.AddAction(ACTION_WATCH_LOSS); context.RegisterReceiver(new ForbidReceiver(), filter); }
public static MainReceiver Create(Context context) { var receiver = new MainReceiver(); var filter = new IntentFilter(); filter.AddAction(Message.Dbg); filter.AddAction(Message.Dist); filter.AddAction(Message.Alarm); context.RegisterReceiver(receiver, filter); return(receiver); }
public override void OnResume() { base.OnResume(); var filter = new IntentFilter(); filter.AddAction(TileEvent.ActionTileOpened); filter.AddAction(TileEvent.ActionTileButtonPressed); filter.AddAction(TileEvent.ActionTileClosed); Application.Context.RegisterReceiver(tileReceiver, filter); }
/// <summary> /// The SetFilters /// </summary> private void SetFilters() { IntentFilter filter = new IntentFilter(); filter.AddAction(ServiceConstants.ACTION_USB_PERMISSION_GRANTED); filter.AddAction(ServiceConstants.ACTION_NO_USB); filter.AddAction(ServiceConstants.ACTION_USB_DISCONNECTED); filter.AddAction(ServiceConstants.ACTION_USB_NOT_SUPPORTED); filter.AddAction(ServiceConstants.ACTION_USB_PERMISSION_NOT_GRANTED); RegisterReceiver(detachedReceiver, filter); }
private void SetupWifiDirect() { _intentFilter = new IntentFilter(); _intentFilter.AddAction(WifiP2pManager.WifiP2pStateChangedAction); _intentFilter.AddAction(WifiP2pManager.WifiP2pPeersChangedAction); _intentFilter.AddAction(WifiP2pManager.WifiP2pConnectionChangedAction); _intentFilter.AddAction(WifiP2pManager.WifiP2pThisDeviceChangedAction); _actionListener = new ActionListener(); _peerListListener = new PeerListListener(); _wifiManager = (WifiP2pManager)SessionsApplication.Context.GetSystemService(Context.WifiP2pService); _wifiChannel = _wifiManager.Initialize(SessionsApplication.Context, SessionsApplication.Context.MainLooper, null); _wifiDirectReceiver = new WifiDirectReceiver(); _wifiDirectReceiver.SetManager(_wifiManager, _wifiChannel, _peerListListener); SessionsApplication.Context.RegisterReceiver(_wifiDirectReceiver, _intentFilter); }
protected override void OnCreate(Bundle bundle) { var intentFilter = new IntentFilter(); intentFilter.AddAction(ConnectivityManager.ConnectivityAction); RegisterReceiver(new Connectivity(), intentFilter); base.OnCreate(bundle); global::Xamarin.Forms.Forms.Init(this, bundle); connectivity.Singleton.MessageEvents.Change += (object s, UIChangedEventArgs ea) => { if (ea.ModuleName == "Notification") { RunOnUiThread(() => { var builder = new Notification.Builder(this) .SetAutoCancel(true) .SetContentTitle("Network state changed") .SetContentText(ea.Info) .SetDefaults(NotificationDefaults.Vibrate) .SetContentText(ea.Info); var notificationManager = (NotificationManager)GetSystemService(NotificationService); notificationManager.Notify(ButtonClickNotificationId, builder.Build()); }); } }; LoadApplication(new App()); }
private void AddReceiver() { var filter = new IntentFilter(); filter.AddAction(IntentFilterName); Receiver = new KillBroadcastReceiver { OnReceiveAction = () => RunOnUiThread(Finish) }; RegisterReceiver(Receiver, filter); }
public override void OnCreate() { base.OnCreate(); nlservicereceiver = new NLSServiceReceiver(); IntentFilter filter = new IntentFilter(); filter.AddAction("com.dpwebdev.handsetfree.NOTIFICATION_LISTENER_SERVICE_EXAMPLE"); RegisterReceiver(nlservicereceiver, filter); }
protected override void OnCreate(Bundle bundle) { base.OnCreate (bundle); var c = new Com.Loopj.Android.Http.AsyncHttpClient (); ROXIMITYEngine.StartEngineWithOptions(this.ApplicationContext, Resource.Drawable.notification_template_icon_bg, null, this, null); _receiver = new BeaconBrodcast (); var intentFilter = new IntentFilter (); intentFilter.AddAction (ROXConsts.MessageFired); intentFilter.AddAction (ROXConsts.BeaconRangeUpdate); RegisterReceiver (_receiver, intentFilter); global::Xamarin.Forms.Forms.Init (this, bundle); LoadApplication (new App ()); }
/// <summary> /// OnCreate called when the activity is launched from cold or after the app /// has been killed due to a higher priority app needing the memory /// </summary> /// <param name='savedInstanceState'> /// Saved instance state. /// </param> protected override void OnCreate (Bundle savedInstanceState) { RequestWindowFeature(WindowFeatures.NoTitle); base.OnCreate(savedInstanceState); IntentFilter filter = new IntentFilter(); filter.AddAction(Intent.ActionScreenOff); filter.AddAction(Intent.ActionScreenOn); filter.AddAction(Intent.ActionUserPresent); screenReceiver = new ScreenReceiver(); RegisterReceiver(screenReceiver, filter); _orientationListener = new OrientationListener(this); Game.Activity = this; }
public override void OnCreate() { base.OnCreate(); _screenOffReceiver = new ScreenOffReceiver(); IntentFilter filter = new IntentFilter(); filter.AddAction(Intent.ActionScreenOff); RegisterReceiver(_screenOffReceiver, filter); }
/// <summary> /// OnCreate called when the activity is launched from cold or after the app /// has been killed due to a higher priority app needing the memory /// </summary> /// <param name='savedInstanceState'> /// Saved instance state. /// </param> protected override void OnCreate (Bundle savedInstanceState) { base.OnCreate (savedInstanceState); o = new OrientationListener(this); if (o.CanDetectOrientation()) { o.Enable(); } IntentFilter filter = new IntentFilter(); filter.AddAction(Intent.ActionScreenOff); filter.AddAction(Intent.ActionScreenOn); filter.AddAction(Intent.ActionUserPresent); screenReceiver = new ScreenReceiver(); RegisterReceiver(screenReceiver, filter); RequestWindowFeature(WindowFeatures.NoTitle); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); _ioc = App.Kp2a.GetDb().Ioc; _intentReceiver = new LockingClosePreferenceActivityBroadcastReceiver(this); IntentFilter filter = new IntentFilter(); filter.AddAction(Intents.DatabaseLocked); RegisterReceiver(_intentReceiver, filter); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); _design.ApplyTheme(); if (PreferenceManager.GetDefaultSharedPreferences(this).GetBoolean( GetString(Resource.String.ViewDatabaseSecure_key), true)) { Window.SetFlags(WindowManagerFlags.Secure, WindowManagerFlags.Secure); } _ioc = App.Kp2a.GetDb().Ioc; _intentReceiver = new LockCloseListActivityBroadcastReceiver(this); IntentFilter filter = new IntentFilter(); filter.AddAction(Intents.DatabaseLocked); filter.AddAction(Intent.ActionScreenOff); RegisterReceiver(_intentReceiver, filter); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.receiver_demo); _receiver = new BatteryReceiver(); var intentFilter = new IntentFilter(Intent.ActionPowerConnected); intentFilter.AddAction(Intent.ActionPowerDisconnected); RegisterReceiver(_receiver, intentFilter); }
public override void OnResume () { base.OnResume (); UpdateNotesTab (); // Start listening for time updates to adjust "now" bar. TIME_TICK is // triggered once per minute, which is how we move the bar over time. IntentFilter filter = new IntentFilter (); filter.AddAction (Intent.ActionPackageAdded); filter.AddAction (Intent.ActionPackageRemoved); filter.AddAction (Intent.ActionPackageReplaced); filter.AddDataScheme ("package"); Activity.RegisterReceiver (packageChangesReceiver, filter); }
protected override void OnResume() { base.OnResume (); // Handle any Google Play services errors if (PlayServicesUtils.IsGooglePlayStoreAvailable (this)) { PlayServicesUtils.HandleAnyPlayServicesError (this); } // Use local broadcast manager to receive registration events to update the channel IntentFilter channelIdUpdateFilter; channelIdUpdateFilter = new IntentFilter (); channelIdUpdateFilter.AddAction (UrbanAirshipReceiver.ACTION_CHANNEL_UPDATED); LocalBroadcastManager.GetInstance (this).RegisterReceiver (channelIdUpdateReceiver, channelIdUpdateFilter); // Update the channel field UpdateChannelIdField (); }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); // Set our view from the "main" layout resource SetContentView(Resource.Layout.Main); txtView = (TextView)FindViewById(Resource.Id.tbNotificationInfo); //txtView = (TextView)FindViewById(Resource.Id.textView1); nReceiver = new NotificationReceiver(); IntentFilter filter = new IntentFilter(); filter.AddAction("com.dpwebdev.handsetfree.NOTIFICATION_LISTENER_EXAMPLE"); RegisterReceiver(nReceiver, filter); // Get our button from the layout resource, // and attach an event to it Button createButton = FindViewById<Button>(Resource.Id.MyButton); Button catchButton = FindViewById<Button>(Resource.Id.catchNotification); createButton.Click += delegate { NotificationManager nManager = (NotificationManager)GetSystemService(NotificationListenerService.NotificationService); Notification.Builder ncomp = new Notification.Builder(this); ncomp.SetContentTitle("My Notification"); ncomp.SetContentText("Notification Listener Service Example"); ncomp.SetTicker("Notification Listener Service Example"); ncomp.SetSmallIcon(Resource.Drawable.Icon); ncomp.SetAutoCancel(true); nManager.Notify(DateTime.Now.Millisecond, ncomp.Build()); }; catchButton.Click += delegate { Intent i = new Intent("com.dpwebdev.handsetfree.NOTIFICATION_LISTENER_SERVICE_EXAMPLE"); i.PutExtra("command", "list"); SendBroadcast(i); }; }
protected override void OnCreate (Bundle savedInstanceState) { base.OnCreate (savedInstanceState); SetContentView (Resource.Layout.location); networkUpdateButton = (Button)FindViewById (Resource.Id.network_update_button); gpsUpdateButton = (Button)FindViewById (Resource.Id.gps_update_button); locationFilter = new IntentFilter (); locationFilter.AddAction (UALocationManager.ActionLocationUpdate); newCriteria = new Criteria (); newCriteria.Accuracy = Accuracy.Fine; networkUpdateButton.Click += delegate { try { UALocationManager.Shared ().RecordCurrentLocation (); } catch (ServiceNotBoundException e) { Logger.Debug (e.Message); } catch (RemoteException e) { Logger.Debug (e.Message); } }; gpsUpdateButton.Click += delegate { try { UALocationManager.Shared ().RecordCurrentLocation (newCriteria); } catch (ServiceNotBoundException e) { Logger.Debug (e.Message); } catch (RemoteException e) { Logger.Debug (e.Message); } }; }
public override StartCommandResult OnStartCommand(Intent intent, StartCommandFlags flags, int startId) { Kp2aLog.Log("Received intent to provide access to entry"); _stopOnLockBroadcastReceiver = new StopOnLockBroadcastReceiver(this); IntentFilter filter = new IntentFilter(); filter.AddAction(Intents.DatabaseLocked); RegisterReceiver(_stopOnLockBroadcastReceiver, filter); if ((intent.Action == Intents.ShowNotification) || (intent.Action == Intents.UpdateKeyboard)) { String uuidBytes = intent.GetStringExtra(EntryActivity.KeyEntry); PwUuid entryId = PwUuid.Zero; if (uuidBytes != null) entryId = new PwUuid(MemUtil.HexStringToByteArray(uuidBytes)); PwEntryOutput entry; try { if ((App.Kp2a.GetDb().LastOpenedEntry != null) && (entryId.Equals(App.Kp2a.GetDb().LastOpenedEntry.Uuid))) { entry = App.Kp2a.GetDb().LastOpenedEntry; } else { entry = new PwEntryOutput(App.Kp2a.GetDb().Entries[entryId], App.Kp2a.GetDb().KpDatabase); } } catch (Exception) { //seems like restarting the service happened after closing the DB StopSelf(); return StartCommandResult.NotSticky; } if (intent.Action == Intents.ShowNotification) { //first time opening the entry -> bring up the notifications bool closeAfterCreate = intent.GetBooleanExtra(EntryActivity.KeyCloseAfterCreate, false); DisplayAccessNotifications(entry, closeAfterCreate); } else //UpdateKeyboard { #if !EXCLUDE_KEYBOARD //this action is received when the data in the entry has changed (e.g. by plugins) //update the keyboard data. //Check if keyboard is (still) available if (Keepass2android.Kbbridge.KeyboardData.EntryId == entry.Uuid.ToHexString()) MakeAccessibleForKeyboard(entry); #endif } } if (intent.Action == Intents.CopyStringToClipboard) { TimeoutCopyToClipboard(intent.GetStringExtra(_stringtocopy)); } if (intent.Action == Intents.ActivateKeyboard) { ActivateKp2aKeyboard(); } if (intent.Action == Intents.ClearNotificationsAndData) { ClearNotifications(); } return StartCommandResult.RedeliverIntent; }
public override void OnResume () { base.OnResume (); // Since we build our views manually instead of using an adapter, we // need to manually requery every time launched. Requery(); Activity.ContentResolver.RegisterContentObserver(ScheduleContract.Sessions.CONTENT_URI, true, mSessionChangesObserver); // Start listening for time updates to adjust "now" bar. TIME_TICK is // triggered once per minute, which is how we move the bar over time. IntentFilter filter = new IntentFilter(); filter.AddAction(Intent.ActionTimeTick); filter.AddAction(Intent.ActionTimeChanged); filter.AddAction(Intent.ActionTimezoneChanged); Activity.RegisterReceiver(mReceiver, filter, null, new Handler()); }
/// <summary> /// Ons the start. /// </summary> /// <param name='intent'> Intent.</param> /// <param name='startId'>Start identifier.</param> public override void OnStart(Intent intent, int startId) { base.OnStart(intent, startId); stop(); episode = EpisodeList.SelectedEpisode; player = MediaPlayer.Create(PortaPodderApp.Context, Android.Net.Uri.Parse(PortaPodderDataSource.GetEpisodeLocation(episode))); // set the player to update the episode current position whenever a seek operation is sent player.SeekComplete += delegate(object sender, EventArgs e) { episode.PlayerPosition = player.CurrentPosition; }; // there is not duration meta-data to be had in the gpodder data structures, so we need to determine it once the media player has // been created and set it at this time and then broadcast it episode.Duration = player.Duration; // go to the last recorded position and start playing from there player.SeekTo(episode.PlayerPosition); player.Start(); // the progress monitor is the background thread which is going to send broadcasts about how far along the player is progressMonitor.Stop = false; if(!progressMonitor.IsRunning) { progressMonitor.Execute(); } // now bind an incoming message reciever for operations IntentFilter intentToReceiveFilter = new IntentFilter(); intentToReceiveFilter.AddAction(PLAYER_INSTRUCTION_SEEK_RELATIVE_FORWARD); intentToReceiveFilter.AddAction(PLAYER_INSTRUCTION_SEEK_RELATIVE_BACKWARD); intentToReceiveFilter.AddAction(PLAYER_INSTRUCTION_SEEK_ABSOLUTE); this.RegisterReceiver(reciever, intentToReceiveFilter, null, handler); receiversRegistered = true; }
public void StartNotification() { if (!started) { metadata = controller.Metadata; playbackState = controller.PlaybackState; // The notification must be updated after setting started to true Notification notification = CreateNotification (); if (notification != null) { controller.RegisterCallback (mCb); var filter = new IntentFilter (); filter.AddAction (ActionNext); filter.AddAction (ActionPause); filter.AddAction (ActionPlay); filter.AddAction (ActionPrev); service.RegisterReceiver (this, filter); service.StartForeground (NotificationId, notification); started = true; } } }
public void DisplayAccessNotifications(PwEntryOutput entry, bool closeAfterCreate) { var hadKeyboardData = ClearNotifications(); String entryName = entry.OutputStrings.ReadSafe(PwDefs.TitleField); ISharedPreferences prefs = PreferenceManager.GetDefaultSharedPreferences(this); var notBuilder = new PasswordAccessNotificationBuilder(this, _notificationManager); if (prefs.GetBoolean(GetString(Resource.String.CopyToClipboardNotification_key), Resources.GetBoolean(Resource.Boolean.CopyToClipboardNotification_default))) { if (entry.OutputStrings.ReadSafe(PwDefs.PasswordField).Length > 0) { notBuilder.AddPasswordAccess(); } if (entry.OutputStrings.ReadSafe(PwDefs.UserNameField).Length > 0) { notBuilder.AddUsernameAccess(); } } bool hasKeyboardDataNow = false; if (prefs.GetBoolean(GetString(Resource.String.UseKp2aKeyboard_key), Resources.GetBoolean(Resource.Boolean.UseKp2aKeyboard_default))) { //keyboard hasKeyboardDataNow = MakeAccessibleForKeyboard(entry); if (hasKeyboardDataNow) { notBuilder.AddKeyboardAccess(); if (prefs.GetBoolean("kp2a_switch_rooted", false)) { //switch rooted bool onlySwitchOnSearch = prefs.GetBoolean(GetString(Resource.String.OpenKp2aKeyboardAutomaticallyOnlyAfterSearch_key), false); if (closeAfterCreate || (!onlySwitchOnSearch)) { ActivateKp2aKeyboard(); } } else { //if the app is about to be closed again (e.g. after searching for a URL and returning to the browser: // automatically bring up the Keyboard selection dialog if ((closeAfterCreate) && prefs.GetBoolean(GetString(Resource.String.OpenKp2aKeyboardAutomatically_key), Resources.GetBoolean(Resource.Boolean.OpenKp2aKeyboardAutomatically_default))) { ActivateKp2aKeyboard(); } } } } if ((!hasKeyboardDataNow) && (hadKeyboardData)) { ClearKeyboard(true); //this clears again and then (this is the point) broadcasts that we no longer have keyboard data } _numElementsToWaitFor = notBuilder.CreateNotifications(entryName); if (_numElementsToWaitFor == 0) { StopSelf(); return; } IntentFilter filter = new IntentFilter(); filter.AddAction(Intents.CopyUsername); filter.AddAction(Intents.CopyPassword); filter.AddAction(Intents.CheckKeyboard); //register receiver to get notified when notifications are discarded in which case we can shutdown the service _notificationDeletedBroadcastReceiver = new NotificationDeletedBroadcastReceiver(this); IntentFilter deletefilter = new IntentFilter(); deletefilter.AddAction(ActionNotificationCancelled); RegisterReceiver(_notificationDeletedBroadcastReceiver, deletefilter); }
private static IntentFilter MakeGattUpdateIntentFilter () { IntentFilter intentFilter = new IntentFilter(); intentFilter.AddAction (BluetoothLeService.ACTION_GATT_CONNECTED); intentFilter.AddAction (BluetoothLeService.ACTION_GATT_DISCONNECTED); intentFilter.AddAction (BluetoothLeService.ACTION_GATT_SERVICES_DISCOVERED); intentFilter.AddAction (BluetoothLeService.ACTION_DATA_AVAILABLE); return intentFilter; }
private void IniciarServico() { //REGISTRAR BROADCAST broadcast = new ClubVipBroadCast(); broadcast.SeloRegistrado += SeloRegistrado; broadcast.RegistroConcluido += RegistroConcluido; broadcast.RegistroCancelado += RegistroCancelado; broadcast.AutenticacaoConcluida += AutenticacaoConcluida; IntentFilter intentFilter = new IntentFilter(); intentFilter.AddAction(ClubVipService.ACTION_SELO_REGISTRADO); intentFilter.AddAction(ClubVipService.ACTION_REGISTRO_CONCLUIDO); intentFilter.AddAction(ClubVipService.ACTION_REGISTRO_CANCELADO); intentFilter.AddAction(ClubVipService.ACTION_AUTENTICADO); RegisterReceiver(broadcast, intentFilter); //INICIAR SERVIÇO Vip vip = new Vip() { CPF = "11175899607", Senha = "9145" }; Intent serviceIntent = new Intent(this, typeof(ClubVipService)); serviceIntent.PutExtra(ClubVipService.EXTRA_VIP, WrapperVip.Serializar(vip)); serviceIntent.PutExtra(ClubVipService.EXTRA_LISTA_SELOS, WrapperSelo.SerializarLista(listaSelos)); StartService(serviceIntent); registrando = true; }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); _design.ApplyTheme(); //use FlagSecure to make sure the last (revealed) character of the password is not visible in recent apps if (PreferenceManager.GetDefaultSharedPreferences(this).GetBoolean( GetString(Resource.String.ViewDatabaseSecure_key), true)) { Window.SetFlags(WindowManagerFlags.Secure, WindowManagerFlags.Secure); } _ioc = App.Kp2a.GetDb().Ioc; if (_ioc == null) { Finish(); return; } SetContentView(Resource.Layout.QuickUnlock); if (App.Kp2a.GetDb().KpDatabase.Name != "") { FindViewById(Resource.Id.filename_label).Visibility = ViewStates.Invisible; ((TextView) FindViewById(Resource.Id.qu_filename)).Text = App.Kp2a.GetDb().KpDatabase.Name; } else { if ( PreferenceManager.GetDefaultSharedPreferences(this) .GetBoolean(GetString(Resource.String.RememberRecentFiles_key), Resources.GetBoolean(Resource.Boolean.RememberRecentFiles_default))) { ((TextView) FindViewById(Resource.Id.qu_filename)).Text = App.Kp2a.GetFileStorage(_ioc).GetDisplayName(_ioc); } else { ((TextView) FindViewById(Resource.Id.qu_filename)).Text = "*****"; } } TextView txtLabel = (TextView) FindViewById(Resource.Id.QuickUnlock_label); int quickUnlockLength = App.Kp2a.QuickUnlockKeyLength; txtLabel.Text = GetString(Resource.String.QuickUnlock_label, new Java.Lang.Object[] {quickUnlockLength}); EditText pwd = (EditText) FindViewById(Resource.Id.QuickUnlock_password); pwd.SetEms(quickUnlockLength); Button btnUnlock = (Button) FindViewById(Resource.Id.QuickUnlock_button); btnUnlock.Click += (object sender, EventArgs e) => { OnUnlock(quickUnlockLength, pwd); }; Button btnLock = (Button) FindViewById(Resource.Id.QuickUnlock_buttonLock); btnLock.Click += (object sender, EventArgs e) => { App.Kp2a.LockDatabase(false); Finish(); }; pwd.EditorAction += (sender, args) => { if ((args.ActionId == ImeAction.Done) || ((args.ActionId == ImeAction.ImeNull) && (args.Event.Action == KeyEventActions.Down))) OnUnlock(quickUnlockLength, pwd); }; _intentReceiver = new QuickUnlockBroadcastReceiver(this); IntentFilter filter = new IntentFilter(); filter.AddAction(Intents.DatabaseLocked); RegisterReceiver(_intentReceiver, filter); }
public async Task StartEventListenersAsync() { #if __ANDROID__ var filter = new IntentFilter(); filter.AddAction(TileEvent.ActionTileOpened); filter.AddAction(TileEvent.ActionTileButtonPressed); filter.AddAction(TileEvent.ActionTileClosed); Application.Context.RegisterReceiver(tileReceiver, filter); #elif __IOS__ client.Native.TileDelegate = tileDelegate; #elif WINDOWS_PHONE_APP await Native.StartReadingsAsync(); #endif }
/// <summary> /// This is the main thread for the Downloader. /// This thread is responsible for queuing up downloads and other goodness. /// </summary> /// <param name="intent"> /// The intent that was recieved. /// </param> protected override void OnHandleIntent(Intent intent) { Log.Debug(Tag,"DownloaderService.OnHandleIntent"); this.IsServiceRunning = true; try { var pendingIntent = (PendingIntent)intent.GetParcelableExtra(DownloaderServiceExtras.PendingIntent); if (null != pendingIntent) { this.downloadNotification.PendingIntent = pendingIntent; this.pPendingIntent = pendingIntent; } else if (null != this.pPendingIntent) { this.downloadNotification.PendingIntent = this.pPendingIntent; } else { Log.Debug(Tag,"LVLDL Downloader started in bad state without notification intent."); return; } // when the LVL check completes, a successful response will update the service if (IsLvlCheckRequired(this.packageInfo)) { this.UpdateLvl(this); return; } // get each download List<DownloadInfo> infos = DownloadsDatabase.GetDownloads(); this.BytesSoFar = 0; this.TotalLength = 0; this.fileCount = infos.Count(); foreach (DownloadInfo info in infos) { // We do an (simple) integrity check on each file, just to // make sure and to verify that the file matches the state if (info.Status == DownloadStatus.Success && !Helpers.DoesFileExist(this, info.FileName, info.TotalBytes, true)) { info.Status = DownloadStatus.None; info.CurrentBytes = 0; } // get aggregate data this.TotalLength += info.TotalBytes; this.BytesSoFar += info.CurrentBytes; } this.PollNetworkState(); if (this.connectionReceiver == null) { // We use this to track network state, such as when WiFi, Cellular, etc. is enabled // when downloads are paused or in progress. this.connectionReceiver = new InnerBroadcastReceiver(this); var intentFilter = new IntentFilter(ConnectivityManager.ConnectivityAction); intentFilter.AddAction(WifiManager.WifiStateChangedAction); this.RegisterReceiver(this.connectionReceiver, intentFilter); } // loop through all downloads and fetch them int types = Enum.GetValues(typeof(ApkExpansionPolicy.ExpansionFileType)).Length; for (int index = 0; index < types; index++) { DownloadInfo info = infos[index]; Log.Debug(Tag,"Starting download of " + info.FileName); long startingCount = info.CurrentBytes; if (info.Status != DownloadStatus.Success) { var dt = new DownloadThread(info, this, this.downloadNotification); this.CancelAlarms(); this.ScheduleAlarm(ActiveThreadWatchdog); dt.Run(); this.CancelAlarms(); } DownloadsDatabase.UpdateFromDatabase(ref info); bool setWakeWatchdog = false; DownloaderState notifyStatus; switch (info.Status) { case DownloadStatus.Forbidden: // the URL is out of date this.UpdateLvl(this); return; case DownloadStatus.Success: this.BytesSoFar += info.CurrentBytes - startingCount; if (index < infos.Count() - 1) { continue; } DownloadsDatabase.UpdateMetadata(this.packageInfo.VersionCode, DownloadStatus.None); this.downloadNotification.OnDownloadStateChanged(DownloaderState.Completed); return; case DownloadStatus.FileDeliveredIncorrectly: // we may be on a network that is returning us a web page on redirect notifyStatus = DownloaderState.PausedNetworkSetupFailure; info.CurrentBytes = 0; DownloadsDatabase.UpdateDownload(info); setWakeWatchdog = true; break; case DownloadStatus.PausedByApp: notifyStatus = DownloaderState.PausedByRequest; break; case DownloadStatus.WaitingForNetwork: case DownloadStatus.WaitingToRetry: notifyStatus = DownloaderState.PausedNetworkUnavailable; setWakeWatchdog = true; break; case DownloadStatus.QueuedForWifi: case DownloadStatus.QueuedForWifiOrCellularPermission: // look for more detail here notifyStatus = this.wifiManager != null && !this.wifiManager.IsWifiEnabled ? DownloaderState.PausedWifiDisabledNeedCellularPermission : DownloaderState.PausedNeedCellularPermission; setWakeWatchdog = true; break; case DownloadStatus.Canceled: notifyStatus = DownloaderState.FailedCanceled; setWakeWatchdog = true; break; case DownloadStatus.InsufficientSpaceError: notifyStatus = DownloaderState.FailedSdCardFull; setWakeWatchdog = true; break; case DownloadStatus.DeviceNotFoundError: notifyStatus = DownloaderState.PausedSdCardUnavailable; setWakeWatchdog = true; break; default: notifyStatus = DownloaderState.Failed; break; } if (setWakeWatchdog) { this.ScheduleAlarm(WatchdogWakeTimer); } else { this.CancelAlarms(); } // failure or pause state this.downloadNotification.OnDownloadStateChanged(notifyStatus); return; } this.downloadNotification.OnDownloadStateChanged(DownloaderState.Completed); } catch (Exception ex) { Log.Error(Tag,ex.Message); Log.Error(Tag,ex.StackTrace); } finally { this.IsServiceRunning = false; } }