Пример #1
1
        public cTestInet(Context c)
        {
            m_Contexto = c;

            m_ConexionINet = false;
            m_TipoConexion = enumTipoConexion.SINCONEXION;
            m_NombreConexion = string.Empty;
            m_VelocidadSubidaReal =  0d;
            m_VelocidadSubidaTeorica = 0d;
            m_VelocidadBajadaReal = 0d;
            m_VelocidadBajadaTeorica = 0d;

            m_GsmSignalStrengthListener = new GsmSignalStrengthListener();
            m_GsmSignalStrengthListener.SignalStrengthChanged += HandleSignalStrengthChanged;

            m_TelefonoManager = (TelephonyManager) m_Contexto.GetSystemService(Context.TelephonyService);
            m_TelefonoManager.Listen(m_GsmSignalStrengthListener, PhoneStateListenerFlags.SignalStrengths);

            m_ConnectivityManager = (ConnectivityManager) m_Contexto.GetSystemService(Context.ConnectivityService);
            m_WifiManager = (WifiManager) m_Contexto.GetSystemService(Context.WifiService);
        }
Пример #2
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate (bundle);
            //Window.AddFlags (WindowManagerFlags.NotTouchable);
            //Window.AddFlags (WindowManagerFlags.NotTouchModal);
            //GetSystemService (WindowManager.UpdateViewLayout);
            // Set our view from the "main" layout resource
            SetContentView (Resource.Layout.Main);
            _UiVideosList = FindViewById<ListView> (Resource.Id.UiVideosList);

            FakeData data = new FakeData ();
            _VideoDB = new VideoBuyDB ();
            _VideoDB.ConnectToDB ("VideoBuyDB.db3");
            _VideoDB.CreateDB ();
            //_VideoDB.Insert (data.allVideos.ToArray ());
            //_VideoDB.SelectBDItems ();

            _VideosListAdapter = new VideosListAdapter (this, _VideoDB.SelectBDItems ().ToArray ());
            _UiVideosList.Adapter = _VideosListAdapter;
            //Intent i = new Intent (this, typeof(IncomingCallReceiver));
            //StartService (i);

            _telephonyManager = (TelephonyManager)GetSystemService (Context.TelephonyService)  as TelephonyManager;
            PhoneStateListener callListener = new PhoneStateListener ();
            PhoneStateListenerFlags callStateListenerFlags = new PhoneStateListenerFlags();
            _telephonyManager.Listen (callListener, PhoneStateListenerFlags.CallState);
        }
Пример #3
0
        protected override void Initialize()
        {
            base.Initialize();

            _telephonyManager = Application.Context.GetSystemService(global::Android.Content.Context.TelephonyService) as TelephonyManager;
            if (_telephonyManager == null)
                throw new Exception("No telephony present.");
        }
Пример #4
0
 public UserInfo( TelephonyManager manager )
 {
    Contract.Requires( manager != null );
    if(manager == null)
    {
       throw new ArgumentNullException( nameof( manager ) );
    }
    m_telephony = manager;
 }
Пример #5
0
        public override void OnReceive(Context context, Intent intent)
        {
            string state = intent.GetStringExtra(TelephonyManager.ExtraState);
             _telephonyManager = (TelephonyManager) context.GetSystemService(Context.TelephonyService) as TelephonyManager;
            PhoneStateListener callListener = new PhoneStateListener ();

            PhoneStateListenerFlags callStateListenerFlags = new PhoneStateListenerFlags();

            //_telephonyManager.Listen (, PhoneStateListenerFlags.CallState);
            _telephonyManager.Listen (callListener, PhoneStateListenerFlags.CallState);
            onCallStateChanged (state, null, context);
        }
Пример #6
0
        /// <summary>
        /// Loads the app.
        /// </summary>
        /// <param name="bundle"></param>
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.Main);
            Window.AddFlags(WindowManagerFlags.KeepScreenOn);
            /*        AdView ad = (AdView) findViewById(Resource.Id.adView);
            ad.loadAd(new AdRequest());*/
            listen = new MyPhoneStateListener(this);
            tm = (TelephonyManager) GetSystemService(TelephonyService);
            tm.Listen(listen, PhoneStateListenerFlags.SignalStrengths);

            setPhoneInfo();
        }
Пример #7
0
		protected override void OnCreate(Bundle bundle)
		{
			base.OnCreate(bundle);
			SetContentView(Resource.Layout.Main);

			_telephonyManager = (TelephonyManager)GetSystemService(Context.TelephonyService);
			_signalStrengthListener = new GsmSignalStrengthListener();

			_gmsStrengthTextView = FindViewById<TextView>(Resource.Id.textView1);
			_gmsStrengthImageView = FindViewById<ImageView>(Resource.Id.imageView1);
			_getGsmSignalStrengthButton = FindViewById<Button>(Resource.Id.myButton);
			_getGsmSignalStrengthButton.Click += DisplaySignalStrength;
		}
Пример #8
0
        /// <summary>
        /// Checks if an intent can be handled.
        /// </summary>
        public static bool IsIntentAvailable(Context context, Intent intent)
        {
            var packageManager = context.PackageManager;

            var list = packageManager.QueryIntentServices(intent, 0)
                       .Union(packageManager.QueryIntentActivities(intent, 0));

            if (list.Any())
            {
                return(true);
            }

            Android.Telephony.TelephonyManager mgr = Android.Telephony.TelephonyManager.FromContext(context);
            return(mgr.PhoneType != PhoneType.None);
        }
Пример #9
0
		protected override void OnCreate(Bundle bundle)
		{
			base.OnCreate(bundle);
			SetContentView(Resource.Layout.Main);

			// Get a reference to the TelephonyManager and instantiate the GsmSignalStrengthListener.
			// These will be used by the Button's OnClick event handler.
			_telephonyManager = (TelephonyManager)GetSystemService(Context.TelephonyService);
			_signalStrengthListener = new GsmSignalStrengthListener();

			_gmsStrengthTextView = FindViewById<TextView>(Resource.Id.textView1);
			_gmsStrengthImageView = FindViewById<ImageView>(Resource.Id.imageView1);
			_getGsmSignalStrengthButton = FindViewById<Button>(Resource.Id.myButton);

			_getGsmSignalStrengthButton.Click += DisplaySignalStrength;
		}
Пример #10
0
        protected override void Initialize()
        {
            base.Initialize();

            if (SensusServiceHelper.Get().ObtainPermission(Permission.Sms) == PermissionStatus.Granted)
            {
                _telephonyManager = Application.Context.GetSystemService(global::Android.Content.Context.TelephonyService) as TelephonyManager;
                if (_telephonyManager == null)
                    throw new NotSupportedException("No telephony present.");
            }
            else
            {
                // throw standard exception instead of NotSupportedException, since the user might decide to enable SMS in the future
                // and we'd like the probe to be restarted at that time.
                string error = "SMS is not permitted on this device. Cannot start SMS probe.";
                SensusServiceHelper.Get().FlashNotificationAsync(error);
                throw new Exception(error);
            }
        }
Пример #11
0
 private void InitializePhoneManager()
 {
     mTelephonyMgr = (TelephonyManager)GetSystemService(TelephonyService);
 }
Пример #12
0
 public static void SetTeleManager(Android.Content.Context a)
 {
     TeleManager = (Android.Telephony.TelephonyManager)a.GetSystemService(Context.TelephonyService);
 }
Пример #13
0
 public static void DestroyReferences()
 {
     TeleManager = null;
 }
Пример #14
0
        /// <summary>
        /// OnCreate
        /// </summary>
        /// <param name="bundle"></param>
        protected override void OnCreate(Bundle bundle)
        {
            try
            {
                base.OnCreate(bundle);

                SetContentView(Resource.Layout.Main);

                _name = FindViewById<TextView>(Resource.Id.txtname);
                _mobileno = FindViewById<TextView>(Resource.Id.txtphoneno);
                _email = FindViewById<TextView>(Resource.Id.txtemailid);
                _ccno = FindViewById<TextView>(Resource.Id.txtccno);
                _login = FindViewById<Button>(Resource.Id.btnsubmit);
                _resp = new StringBuilder();
                _req = new RegistrationRequest();

                _teleMngr = (TelephonyManager)GetSystemService(TelephonyService);
                _mobileno.Text = _teleMngr.Line1Number;

                _login.Click += delegate
                {
                    if (!DoRegistrationValidation())
                    {
                        new AlertDialog.Builder(this)
                        .SetMessage(_resp.ToString())
                        .SetNeutralButton("Ok", delegate { }).Show();
                        return;
                    }

                    try
                    {
                        ConstructRequest();

                        HttpStatusCode respCode = PostRegistrationDetails(URL, _req);

                        if (respCode != HttpStatusCode.OK)
                        {
                            new AlertDialog.Builder(this)
                           .SetMessage(respCode.ToString())
                           .SetNeutralButton("Ok", delegate { }).Show();
                            return;
                        }

                    }
                    catch (Exception ex)
                    {
                        new AlertDialog.Builder(this).SetMessage(ex.Message).Show();
                    }

                    Intent intent = new Intent(this, typeof(HomeActivity));
                    intent.PutExtra("Name", _name.Text);
                    intent.PutExtra("DeviceId", _teleMngr.DeviceId);
                    StartActivity(intent);
                };
            }
            catch (Exception ex)
            {
                new AlertDialog.Builder(this).SetMessage("Oncreate main activity **culprit** "+ex.Message).Show();
            }
        }
        /*
         * Create Method
         * Fires when the activity is started
         */
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            //setting the main layout Main.xml
            SetContentView(Resource.Layout.Main);

            //Getting telephony and wifi information from the system service
            telephonyManager = (TelephonyManager)this.GetSystemService(Context.TelephonyService);
            wifiManager= (WifiManager)this.GetSystemService(Service.WifiService);

            //Declaring the command ubttons
            var cmd_SensorStatus = FindViewById<Button> (Resource.Id.sensorStatusButton);
            var cmd_Calculate = FindViewById<Button> (Resource.Id.cmdCalculate);

            //Adding text view by id
            _deviceIdTextView = FindViewById<TextView> (Resource.Id.textDeviceID);

            batteryStatusTextView = FindViewById<TextView> (Resource.Id.textBatteryStatus);
            batteryLevelTextView = FindViewById<TextView> (Resource.Id.textBatteryLevel);
            batteryVoltageTextView = FindViewById<TextView> (Resource.Id.textBatteryVoltage);
            batteryTemperatureTextView = FindViewById<TextView> (Resource.Id.textBatteryTemperature);
            batteryTechnologyTextView = FindViewById<TextView> (Resource.Id.textBatteryTechnology);

            _IpTextView = FindViewById<TextView> (Resource.Id.textIP);
            //Adding text to the text views from device information
            _deviceIdTextView.Text = telephonyManager.DeviceId.ToString ();

            //Registering battery related information
            registerBatteryLevelReceiver();

            device_ID = _deviceIdTextView.Text;
            device_Info = Build.Manufacturer.ToString ()+ " " + Build.Model.ToString ();

            batteryStatusTextView.Text = battery_status;
            batteryLevelTextView.Text = battery_level.ToString();
            batteryVoltageTextView.Text = battery_voltage.ToString();
            batteryTemperatureTextView.Text = battery_temperature.ToString();
            batteryTechnologyTextView.Text = battery_Technology;

            //locationInfo = telephonyManager.CellLocation.ToString ();

            //Getting localip address
            int ip = wifiManager.ConnectionInfo.IpAddress;
            _IpTextView.Text = string.Format("{0}.{1}.{2}.{3}",(ip & 0xff),(ip >> 8 & 0xff),(ip >> 16 & 0xff),(ip >> 24 & 0xff));

            //Adding even listeners buttons
            cmd_SensorStatus.Click += (object sender, EventArgs e) => {sensorStatusButtonClick();};
            cmd_Calculate.Click += (object sender, EventArgs e) => {calculateButtonClick();};
        }