Пример #1
0
        protected override void OnCreate(Bundle bundle)
        {
            var path = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal);
            _filepath = Path.Combine(path, "CallSlips.txt");
            _position = Intent.GetIntExtra("position", 0);

            base.OnCreate(bundle);
            SetContentView(Resource.Layout.CallSlipDetails);

            _buttonChip = FindViewById<Button>(Resource.Id.chipButton);
            _buttonChip.Click += HandleButtonChipClick;

            var buttonPrint = FindViewById<Button>(Resource.Id.printButton);
            buttonPrint.Click += HandleButtonPrintClick;

            var buttonFound = FindViewById<Button>(Resource.Id.foundButton);
            buttonFound.Click += buttonFound_Click;

            _nfcAdapter = NfcAdapter.GetDefaultAdapter(this);

            _previousButton = FindViewById<Button>(Resource.Id.previousButton);
            _previousButton.Click += HandlePreviousButtonClick;

            _nextButton = FindViewById<Button>(Resource.Id.nextButton);
            _nextButton.Click += HandleNextButtonClick;

            _needsLookupButton = FindViewById<Button>(Resource.Id.needsLookup);
            _needsLookupButton.Click += HandleNeedsLookupButtonClick;

            _barcodeButton = FindViewById<Button>(Resource.Id.barcodeButton);
            _barcodeButton.Click += HandleBarcodeButtonClick;

            FillPage();
        }
Пример #2
0
        public NfcDevice(NfcAdapter adapter)
        {
            this.device = adapter;

            //if (this.device == null)
            //{
            //    throw new NullReferenceException("NFC adapter is null. Either device does not support NFC or the application does not have NFC priviledges.");
            //}

            var app = Resolver.Resolve<IXFormsApp>();
            var tapp = app as IXFormsApp<XFormsApplicationDroid>;

            this.device.SetNdefPushMessageCallback(this, tapp.AppContext);
        }
Пример #3
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate (bundle);

            global::Xamarin.Forms.Forms.Init (this, bundle);

            NfcManager NfcManager = (NfcManager)Android.App.Application.Context.GetSystemService(Context.NfcService);
            NFCdevice = NfcManager.DefaultAdapter;

            Xamarin.Forms.DependencyService.Register<INfcForms,NfcForms>();
            x = Xamarin.Forms.DependencyService.Get<INfcForms>() as NfcForms;

            LoadApplication (new App ());
        }
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.Main);

            // Get a reference to the default NFC adapter for this device. This adapter
            // is how an Android application will interact with the actual hardware.
            _nfcAdapter = NfcAdapter.GetDefaultAdapter(this);

            _writeTagButton = FindViewById<Button>(Resource.Id.write_tag_button);
            _writeTagButton.Click += WriteTagButtonOnClick;

            _textView = FindViewById<TextView>(Resource.Id.text_view);
        }
Пример #5
0
		protected override void OnCreate(Bundle bundle)
		{
			base.OnCreate(bundle);

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

			_inputText = FindViewById<EditText>(Resource.Id.inputText);
			_outputText = FindViewById<TextView>(Resource.Id.outputText);
			_alertMessage = FindViewById<TextView>(Resource.Id.alertMessage);
			_button = FindViewById<Button>(Resource.Id.button);
			_button.Click += WriteTagButtonOnClick;

			// init all that cool shit
			_nfcAdapter = NfcAdapter.GetDefaultAdapter(this);
		}
Пример #6
0
        public NfcDevice(NfcAdapter adapter)
        {
            this.device = adapter;

            if (this.device != null)
            {
                var app = Resolver.Resolve<IXFormsApp>();
                var tapp = app as IXFormsApp<XFormsApplicationDroid>;

                this.device.SetNdefPushMessageCallback(this, tapp.AppContext);
            }
            else
            {
                Android.Util.Log.Info("INfcDevice", "NFC adapter is null. Either device does not support NFC or the application does not have NFC priviledges.");
            }
        }
Пример #7
0
        protected DroidBase()
        {
            _nfcAdapter = NfcAdapter.GetDefaultAdapter(TopActivity);
            if (_nfcAdapter != null)
            {
                string permission = "android.permission.NFC";
                var res = TopActivity.CheckCallingOrSelfPermission(permission);
                if (res == Permission.Denied)
                {
                    Mvx.Error("You don't have permission to read NFC. Please update your manifest file");

                }
                else
                {
                    _haveManifestPermission = true;
                }
            }
        }
Пример #8
0
		/// <summary>
		///     Initializes a new instance of the <see cref="NfcDevice" /> class.
		/// </summary>
		/// <param name="adapter">The adapter.</param>
		public NfcDevice(NfcAdapter adapter)
		{
			_device = adapter;

			if (_device != null)
			{
				//var app = Resolver.Resolve<IXFormsApp>();
				//var tapp = app as IXFormsApp<XFormsApplicationDroid>;

				//_device.SetNdefPushMessageCallback(this, Context.ApplicationInfo.);
				throw new NotImplementedException("Need to get main Application Activity here");
			}
			else
			{
				Log.Info(
					"INfcDevice",
					"NFC adapter is null. Either device does not support NFC or the application does not have NFC priviledges.");
			}
		}
		protected override void OnCreate (Bundle savedInstanceState)
		{
			base.OnCreate (savedInstanceState);
			this.SetContentView (Resource.Layout.Main);

			mInfoText = FindViewById <TextView> (Resource.Id.textView);
			// Check for available NFC Adapter
			mNfcAdapter = NfcAdapter.GetDefaultAdapter (this);

			if (mNfcAdapter == null) {
				mInfoText = FindViewById <TextView> (Resource.Id.textView);
				mInfoText.Text = "NFC is not available on this device.";
			} else {
				// Register callback to set NDEF message
				mNfcAdapter.SetNdefPushMessageCallback (this, this);
				// Register callback to listen for message-sent success
				mNfcAdapter.SetOnNdefPushCompleteCallback (this, this);
			}
		}
Пример #10
0
		public NfcForms ()
		{
			NfcManager NfcManager =	(NfcManager)Android.App.Application.Context.GetSystemService(Context.NfcService);		
			nfcDevice = NfcManager.DefaultAdapter;
		    nfcTag = new NfcFormsTag ();
		}
Пример #11
0
        /// <summary>
        /// Start foreground listening for NFC messages
        /// </summary>
        protected void StartForegroundMonitoring()
        {
            var topActivity = TopActivity;
            if (_nfcAdapter == null)
            {
                _nfcAdapter = NfcAdapter.GetDefaultAdapter(topActivity);
            }
            Type activityType = topActivity.GetType();
            Mvx.Trace(activityType.Name);
            var intent = new Intent(topActivity, activityType).AddFlags(ActivityFlags.SingleTop);
            var pendingIntent = PendingIntent.GetActivity(topActivity, 0, intent, 0);

            var tagDetected = new IntentFilter(NfcAdapter.ActionTagDiscovered);
            var filters = new[] { tagDetected };
            _nfcAdapter.EnableForegroundDispatch(topActivity, pendingIntent, filters, null);
        }