protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            Title = "Bluetooth Devices";

            try
            {
                if (InitDevicesList() == 0)
                {
                    this.Finish();
                    return;
                }
            }
            catch (Exception ex)
            {
                this.Finish();
                return;
            }

            mBTReceiver = new MyBroadcastReceiver(mArrayAdapter);

            IntentFilter btIntentFilter = new IntentFilter(
                BluetoothDevice.ActionFound);

            RegisterReceiver(mBTReceiver, btIntentFilter);
        }
        public DocumentDownloadHelper(int DocumentID, Activity context)
        {
            this.DocumentID = DocumentID;
            this.context    = context;

            broadcastReceiver = new MyBroadcastReceiver(this);
        }
        public override void OnCreate()
        {
            try
            {
                base.OnCreate();
                Service = this;

                Task.Run(() =>
                {
                    GlobalContext        = HomeActivity.GetInstance();
                    MNotificationManager = (NotificationManager)GetSystemService(NotificationService);

                    OnCallIncome = new MyBroadcastReceiver();

                    RegisterReceiver(OnCallIncome, new IntentFilter("android.intent.action.PHONE_STATE"));
                });

                if (Constant.ArrayListPlay.Count > 0)
                {
                    CreateNoti();
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
Exemple #4
0
        private void RegisterBroadcastReceiver()
        {
            IntentFilter filter = new IntentFilter(MyBroadcastReceiver.LOCATION_UPDATED);

            filter.AddCategory(Intent.CategoryDefault);
            _receiver = new MyBroadcastReceiver();
            RegisterReceiver(_receiver, filter);
        }
        public override void OnCreate(Bundle p0)
        {
            base.OnCreate(p0);
            mHandler = new NotifyingAsyncQueryHandler(Activity.ContentResolver, this);
            mSessionChangesObserver = new SessionChangesObserver(this);
            mReceiver = new MyBroadcastReceiver(this);

            SetHasOptionsMenu(true);
            //AnalyticsUtils.getInstance(Activity).trackPageView("/Schedule");
        }
Exemple #6
0
 public CustomScanner(Context context)
     : base(context)
 {
     UsbConnection = new MyServiceConnection(this);
     mUsbReceiver  = new MyBroadcastReceiver();
     mHandler      = new MyHandler(this);
     IsTurned      = false;
     SetFilters();  // Start listening notifications from UsbService
     StartService(typeof(WrapperUsbService), UsbConnection, null);
 }
Exemple #7
0
        protected override void OnStart()
        {
            base.OnStart();

            if (_intentReceiver == null)
            {
                _intentReceiver = new MyBroadcastReceiver(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.game_instructions);

            TextView Battery_Level_TextView = FindViewById <TextView>(Resource.Id.Battery_Level_TextView);

            // BroadcastReceiver.

            IntentFilter IntentFilter = new IntentFilter(Intent.ActionBatteryChanged);

            MyBroadcastReceiver BroadcastReceiver = new MyBroadcastReceiver(Battery_Level_TextView);

            RegisterReceiver(BroadcastReceiver, IntentFilter);
        }
Exemple #9
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            BluetoothAdapter mBluetoothAdapter;

            base.OnCreate(savedInstanceState);


            bInstance         = this;
            mBluetoothAdapter = BluetoothAdapter.DefaultAdapter;

            IntentFilter filter = new IntentFilter(BluetoothDevice.ActionFound);

            mReceiver = new MyBroadcastReceiver();
            IntentFilter filterF = new IntentFilter(BluetoothAdapter.ActionDiscoveryFinished);
            IntentFilter filterS = new IntentFilter(BluetoothAdapter.ActionDiscoveryStarted);

            RegisterReceiver(mReceiver, filter);
            RegisterReceiver(mReceiver, filterF);
            RegisterReceiver(mReceiver, filterS);

            StartAsyncDisc(mBluetoothAdapter);
        }
Exemple #10
0
 /// <summary>
 /// Default ctor
 /// </summary>
 public DeviceListActivity()
 {
     mReceiver = new MyBroadcastReceiver(this);
 }
 /// <summary>
 /// Default ctor
 /// </summary>
 public DeviceListActivity()
 {
     mReceiver = new MyBroadcastReceiver(this);
 }
Exemple #12
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.open_db_selection);

            var toolbar = FindViewById <Android.Support.V7.Widget.Toolbar>(Resource.Id.mytoolbar);

            SetSupportActionBar(toolbar);

            SupportActionBar.Title = GetString(Resource.String.select_database);


            //only load the AppTask if this is the "first" OnCreate (not because of kill/resume, i.e. savedInstanceState==null)
            // and if the activity is not launched from history (i.e. recent tasks) because this would mean that
            // the Activity was closed already (user cancelling the task or task complete) but is restarted due recent tasks.
            // Don't re-start the task (especially bad if tak was complete already)
            if (Intent.Flags.HasFlag(ActivityFlags.LaunchedFromHistory))
            {
                AppTask = new NullTask();
            }
            else
            {
                AppTask = AppTask.GetTaskInOnCreate(savedInstanceState, Intent);
            }

            _adapter = new OpenDatabaseAdapter(this);
            var gridView = FindViewById <GridView>(Resource.Id.gridview);

            gridView.Adapter = _adapter;

            if (!string.IsNullOrEmpty(Intent.GetStringExtra(Util.KeyFilename)))
            {
                //forward to password activity
                Intent           i   = new Intent(this, typeof(PasswordActivity));
                IOConnectionInfo ioc = new IOConnectionInfo();
                Util.SetIoConnectionFromIntent(ioc, Intent);
                Util.PutIoConnectionToIntent(ioc, i);
                i.PutExtra(PasswordActivity.KeyKeyfile, i.GetStringExtra(PasswordActivity.KeyKeyfile));
                i.PutExtra(PasswordActivity.KeyPassword, i.GetStringExtra(PasswordActivity.KeyPassword));
                LaunchingOther = true;
                StartActivityForResult(i, ReqCodeOpenNewDb);
            }
            else
            {
                if (Intent.Action == Intent.ActionView)
                {
                    GetIocFromViewIntent(Intent);
                }
                else if (Intent.Action == Intent.ActionSend)
                {
                    AppTask = new SearchUrlTask {
                        UrlToSearchFor = Intent.GetStringExtra(Intent.ExtraText)
                    };
                }
            }

            _intentReceiver = new MyBroadcastReceiver(this);
            IntentFilter filter = new IntentFilter();

            filter.AddAction(Intents.DatabaseLocked);
            RegisterReceiver(_intentReceiver, filter);
        }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);

            // Create broadcast receiver instance
            mMessageReceiver          = new MyBroadcastReceiver();
            mMessageReceiver.Receive += delegate(Intent intent) { HandleDecodeData(intent); };

            tv_results = FindViewById <TextView>(Resource.Id.tv_results);
            sv_results = FindViewById <ScrollView>(Resource.Id.sv_results);


            // Setup buttons behaviors
            Button btStart = FindViewById <Button>(Resource.Id.button_start);

            btStart.Click += delegate
            {
                SendDataWedgeIntentWithExtra(DataWedgeConstants.DWAPI_ACTION_SOFTSCANTRIGGER, DataWedgeConstants.EXTRA_PARAMETER, DataWedgeConstants.DWAPI_START_SCANNING);
            };

            Button btStop = FindViewById <Button>(Resource.Id.button_stop);

            btStop.Click += delegate
            {
                SendDataWedgeIntentWithExtra(DataWedgeConstants.DWAPI_ACTION_SOFTSCANTRIGGER, DataWedgeConstants.EXTRA_PARAMETER, DataWedgeConstants.DWAPI_STOP_SCANNING);
            };

            Button btToggle = FindViewById <Button>(Resource.Id.button_toggle);

            btToggle.Click += delegate
            {
                SendDataWedgeIntentWithExtra(DataWedgeConstants.DWAPI_ACTION_SOFTSCANTRIGGER, DataWedgeConstants.EXTRA_PARAMETER, DataWedgeConstants.DWAPI_TOGGLE_SCANNING);
            };

            Button btEnable = FindViewById <Button>(Resource.Id.button_enable);

            btEnable.Click += delegate
            {
                SendDataWedgeIntentWithExtra(DataWedgeConstants.DWAPI_ACTION_SCANNERINPUTPLUGIN, DataWedgeConstants.EXTRA_PARAMETER, DataWedgeConstants.DWAPI_PARAMETER_SCANNERINPUTPLUGIN_ENABLE);
            };

            Button btDisable = FindViewById <Button>(Resource.Id.button_disable);

            btDisable.Click += delegate
            {
                SendDataWedgeIntentWithExtra(DataWedgeConstants.DWAPI_ACTION_SCANNERINPUTPLUGIN, DataWedgeConstants.EXTRA_PARAMETER, DataWedgeConstants.DWAPI_PARAMETER_SCANNERINPUTPLUGIN_DISABLE);
            };

            Button btCreate = FindViewById <Button>(Resource.Id.button_create);

            btCreate.Click += delegate
            {
                CreateProfileAsync();
            };

            Button btImport = FindViewById <Button>(Resource.Id.button_import);

            btImport.Click += delegate
            {
                ImportProfile("dwprofile_datacapture");
            };

            Button btDelete = FindViewById <Button>(Resource.Id.button_delete);

            btDelete.Click += delegate
            {
                DeleteProfile();
            };

            Button btSwitch = FindViewById <Button>(Resource.Id.button_switch);

            btSwitch.Click += delegate
            {
                SwitchScannerParamsAsync();
            };

            Button btClear = FindViewById <Button>(Resource.Id.button_clear);

            btClear.Click += delegate
            {
                mResults        = "";
                tv_results.Text = mResults;
            };


            if (this.Intent != null)
            {
                HandleDecodeData(this.Intent);
            }
        }
        // inspired by http://baroqueworksdev.blogspot.com/2012/09/how-to-handle-screen-onoff-and-keygurad.html



        protected override void onCreate(global::android.os.Bundle savedInstanceState)
        {
            base.onCreate(savedInstanceState);

            var sv = new ScrollView(this);
            var ll = new LinearLayout(this);
            ll.setOrientation(LinearLayout.VERTICAL);
            sv.addView(ll);


            this.setContentView(sv);


            new Button(this).WithText("register").AttachTo(ll).AtClick(
                btn =>
                {
                    btn.setEnabled(false);

                    // get KeyGuardManager
                    var mKeyguard = (KeyguardManager)getSystemService(Context.KEYGUARD_SERVICE);

                    var mReceiver = new MyBroadcastReceiver();

                    mReceiver.AtReceive +=
                        (Context context, Intent intent) =>
                        {
                            #region Notify
                            int counter = 0;
                            Action<string> Notify =
                                Title =>
                                {
                                    counter++;

                                    var nm = (NotificationManager)this.getSystemService(Activity.NOTIFICATION_SERVICE);

                                    // see http://developer.android.com/reference/android/app/Notification.html
                                    var notification = new Notification(
                                        android.R.drawable.star_on,
                                        Title,
                                         java.lang.System.currentTimeMillis()
                                    );

                                    // ToClass is like GetTypeInfo
                                    var notificationIntent = new Intent(this, typeof(AndroidUnlockActivity).ToClass());
                                    var contentIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0);


                                    notification.setLatestEventInfo(
                                        this,
                                        Title,
                                        "",
                                        contentIntent);

                                    // http://stackoverflow.com/questions/10402686/how-to-have-led-light-notification
                                    notification.defaults |= Notification.DEFAULT_VIBRATE;
                                    notification.defaults |= Notification.DEFAULT_SOUND;
                                    //notification.defaults |= Notification.DEFAULT_LIGHTS;
                                    notification.defaults |= Notification.FLAG_SHOW_LIGHTS;
                                    // http://androiddrawableexplorer.appspot.com/
                                    nm.notify(counter, notification);

                                    //context.ToNotification(
                                    //      Title: Title,
                                    //      Content: Title,

                                    //      id: (int)java.lang.System.currentTimeMillis(),
                                    //        icon: android.R.drawable.star_on,
                                    //      uri: "http://my.jsc-solutions.net"
                                    //  );
                                };
                            #endregion

                            var action = intent.getAction();
                            if (action == Intent.ACTION_SCREEN_OFF)
                            {
                                // Screen is off
                                Notify("ACTION_SCREEN_OFF");
                            }
                            else if (action == Intent.ACTION_SCREEN_ON)
                            {
                                // Intent.ACTION_USER_PRESENT will be broadcast when the screen
                                // is
                                // unlocked.

                                // if API Level 16
                                /*
                                 * if(mKeyguard.isKeyguardLocked()){ // the keyguard is
                                 * currently locked. Log.e("","ACTION_SCREEN_ON : locked"); }
                                 */
                                if (mKeyguard.inKeyguardRestrictedInputMode())
                                {
                                    // the keyguard is currently locked.
                                    Notify("ACTION_SCREEN_ON : locked");
                                }
                                else
                                {
                                    // unlocked
                                    Notify("ACTION_SCREEN_ON : unlocked");
                                }

                            }
                            else if (action == Intent.ACTION_USER_PRESENT)
                            {
                                // The user has unlocked the screen. Enabled!
                                Notify("ACTION_USER_PRESENT");


                            }
                        };


                    // IntetFilter with Action
                    IntentFilter intentFilter = new IntentFilter();
                    intentFilter.addAction(Intent.ACTION_SCREEN_OFF);
                    intentFilter.addAction(Intent.ACTION_SCREEN_ON);
                    intentFilter.addAction(Intent.ACTION_USER_PRESENT);// Keyguard is GONE

                    // register BroadcastReceiver and IntentFilter
                    registerReceiver(mReceiver, intentFilter);
                }
            );

            //this.ShowToast("http://jsc-solutions.net");
        }
		public override void OnCreate (Bundle p0)
		{
			base.OnCreate (p0);
			mHandler = new NotifyingAsyncQueryHandler(Activity.ContentResolver, this);
			mSessionChangesObserver = new SessionChangesObserver(this);
			mReceiver = new MyBroadcastReceiver(this);
			
	        SetHasOptionsMenu(true);
	        //AnalyticsUtils.getInstance(Activity).trackPageView("/Schedule");
		}
Exemple #16
0
        // inspired by http://baroqueworksdev.blogspot.com/2012/09/how-to-handle-screen-onoff-and-keygurad.html



        protected override void onCreate(global::android.os.Bundle savedInstanceState)
        {
            base.onCreate(savedInstanceState);

            var sv = new ScrollView(this);
            var ll = new LinearLayout(this);

            ll.setOrientation(LinearLayout.VERTICAL);
            sv.addView(ll);


            this.setContentView(sv);


            new Button(this).WithText("register").AttachTo(ll).AtClick(
                btn =>
            {
                btn.setEnabled(false);

                // get KeyGuardManager
                var mKeyguard = (KeyguardManager)getSystemService(Context.KEYGUARD_SERVICE);

                var mReceiver = new MyBroadcastReceiver();

                mReceiver.AtReceive +=
                    (Context context, Intent intent) =>
                {
                    #region Notify
                    int counter            = 0;
                    Action <string> Notify =
                        Title =>
                    {
                        counter++;

                        var nm = (NotificationManager)this.getSystemService(Activity.NOTIFICATION_SERVICE);

                        // see http://developer.android.com/reference/android/app/Notification.html
                        var notification = new Notification(
                            android.R.drawable.star_on,
                            Title,
                            java.lang.System.currentTimeMillis()
                            );

                        // ToClass is like GetTypeInfo
                        var notificationIntent = new Intent(this, typeof(AndroidUnlockActivity).ToClass());
                        var contentIntent      = PendingIntent.getActivity(this, 0, notificationIntent, 0);


                        notification.setLatestEventInfo(
                            this,
                            Title,
                            "",
                            contentIntent);

                        // http://stackoverflow.com/questions/10402686/how-to-have-led-light-notification
                        notification.defaults |= Notification.DEFAULT_VIBRATE;
                        notification.defaults |= Notification.DEFAULT_SOUND;
                        //notification.defaults |= Notification.DEFAULT_LIGHTS;
                        notification.defaults |= Notification.FLAG_SHOW_LIGHTS;
                        // http://androiddrawableexplorer.appspot.com/
                        nm.notify(counter, notification);

                        //context.ToNotification(
                        //      Title: Title,
                        //      Content: Title,

                        //      id: (int)java.lang.System.currentTimeMillis(),
                        //        icon: android.R.drawable.star_on,
                        //      uri: "http://my.jsc-solutions.net"
                        //  );
                    };
                    #endregion

                    var action = intent.getAction();
                    if (action == Intent.ACTION_SCREEN_OFF)
                    {
                        // Screen is off
                        Notify("ACTION_SCREEN_OFF");
                    }
                    else if (action == Intent.ACTION_SCREEN_ON)
                    {
                        // Intent.ACTION_USER_PRESENT will be broadcast when the screen
                        // is
                        // unlocked.

                        // if API Level 16

                        /*
                         * if(mKeyguard.isKeyguardLocked()){ // the keyguard is
                         * currently locked. Log.e("","ACTION_SCREEN_ON : locked"); }
                         */
                        if (mKeyguard.inKeyguardRestrictedInputMode())
                        {
                            // the keyguard is currently locked.
                            Notify("ACTION_SCREEN_ON : locked");
                        }
                        else
                        {
                            // unlocked
                            Notify("ACTION_SCREEN_ON : unlocked");
                        }
                    }
                    else if (action == Intent.ACTION_USER_PRESENT)
                    {
                        // The user has unlocked the screen. Enabled!
                        Notify("ACTION_USER_PRESENT");
                    }
                };


                // IntetFilter with Action
                IntentFilter intentFilter = new IntentFilter();
                intentFilter.addAction(Intent.ACTION_SCREEN_OFF);
                intentFilter.addAction(Intent.ACTION_SCREEN_ON);
                intentFilter.addAction(Intent.ACTION_USER_PRESENT);    // Keyguard is GONE

                // register BroadcastReceiver and IntentFilter
                registerReceiver(mReceiver, intentFilter);
            }
                );

            //this.ShowToast("http://jsc-solutions.net");
        }