예제 #1
0
        public static void BecomeHomeActivity(Context c)
        {
            ComponentName       deviceAdmin = new ComponentName(c, "AdminReceiver");
            DevicePolicyManager dpm         = (DevicePolicyManager)c.GetSystemService(Context.DevicePolicyService);

            dpm.SetLockTaskPackages(deviceAdmin, new string[] { "br.com.AndroidTest" });

            if (!dpm.IsAdminActive(deviceAdmin))
            {
                showToast(c, "This app is not a device admin!");
                return;
            }
            if (!dpm.IsDeviceOwnerApp(c.PackageName))
            {
                showToast(c, "This app is not the device owner!");
                return;
            }
            IntentFilter intentFilter = new IntentFilter(Intent.ActionMain);

            intentFilter.AddCategory(Intent.CategoryDefault);
            intentFilter.AddCategory(Intent.CategoryHome);
            ComponentName activity = new ComponentName(c, "MainActivity");

            dpm.AddPersistentPreferredActivity(deviceAdmin, intentFilter, activity);
            showToast(c, "Home activity: " + GetHomeActivity(c));
        }
예제 #2
0
 private void RegisterBroadcastReceiver()
 {
     IntentFilter filter = new IntentFilter(GPSServiceReciever.LOCATION_UPDATED);
     filter.AddCategory(Intent.CategoryDefault);
     _receiver = new GPSServiceReciever();
     RegisterReceiver(_receiver, filter);
 }
예제 #3
0
        /// <summary>
        /// Starts tags detection
        /// </summary>
        public void StartListening()
        {
            if (_nfcAdapter == null)
            {
                return;
            }

            var intent        = new Intent(CurrentActivity, CurrentActivity.GetType()).AddFlags(ActivityFlags.SingleTop);
            var pendingIntent = PendingIntent.GetActivity(CurrentActivity, 0, intent, 0);

            var ndefFilter = new IntentFilter(NfcAdapter.ActionNdefDiscovered);

            ndefFilter.AddDataType("*/*");

            var tagFilter = new IntentFilter(NfcAdapter.ActionTagDiscovered);

            tagFilter.AddCategory(Intent.CategoryDefault);

            var filters = new IntentFilter[] { ndefFilter, tagFilter };

            _nfcAdapter.EnableForegroundDispatch(CurrentActivity, pendingIntent, filters, null);

            _isListening = true;
            OnTagListeningStatusChanged?.Invoke(_isListening);
        }
예제 #4
0
 static sScanner()
 {
     Filter   = new IntentFilter("com.espack.SCAN");
     Receiver = new ScanReceiver();
     Filter.AddCategory(Intent.CategoryDefault);
     IsBusy = false;
 }
예제 #5
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            // Neue Instanz des NfcAdapters dieses Smartphones
            _nfcAdapter = NfcAdapter.GetDefaultAdapter(ApplicationContext);

            // Ansicht von der "Main"-Layout-Ressource darstellen.
            SetContentView(Resource.Layout.Main);

            TabLayout tabLayout = (TabLayout)FindViewById(Resource.Id.tablayout_navigation);

            ViewPager viewPager = (ViewPager)FindViewById(Resource.Id.pager);

            SetupViewPager(viewPager);

            tabLayout.SetupWithViewPager(viewPager);

            var intent = new Intent(this, this.Class);

            intent.AddFlags(ActivityFlags.SingleTop);
            nfcPi     = PendingIntent.GetActivity(this, 0, intent, 0);
            nfcFilter = new IntentFilter(NfcAdapter.ActionTechDiscovered);
            nfcFilter.AddCategory(Intent.CategoryDefault);
        }
예제 #6
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            EMDKResults result = EMDKManager.GetEMDKManager(Application.Context, this);

            if (result.StatusCode != EMDKResults.STATUS_CODE.Success)
            {
                Toast.MakeText(this, "Error opening the EMDK Manager", ToastLength.Long).Show();
            }
            else
            {
                Toast.MakeText(this, "EMDK Manager is available", ToastLength.Long).Show();
            }


            ScanReceiver _broadcastReceiver = new ScanReceiver();

            global::Xamarin.Forms.Forms.Init(this, bundle);
            var my_application = new App();

            _broadcastReceiver.scanDataReceived += (s, scanData) =>
            {
                MessagingCenter.Send <App, string> (my_application, "ScanBarcode", scanData);
            };

            // Register the broadcast receiver
            IntentFilter filter = new IntentFilter(ScanReceiver.IntentAction);

            filter.AddCategory(ScanReceiver.IntentCategory);
            Android.App.Application.Context.RegisterReceiver(_broadcastReceiver, filter);

            LoadApplication(my_application);
        }
예제 #7
0
        private void RegisterBroadcastReceiver()
        {
            IntentFilter filter = new IntentFilter(GPSServiceReciever.LOCATION_UPDATED);

            filter.AddCategory(Intent.CategoryDefault);
            _receiver = new GPSServiceReciever();
            RegisterReceiver(_receiver, filter);
        }
예제 #8
0
 /// <summary>
 /// register to service
 /// </summary>
 private void RegisterBroadcastReceiver()
 {
     IntentFilter filter = new IntentFilter(MsgBroadcasrReceiver.MSG_BCAST);
     filter.AddCategory(Intent.CategoryDefault);
     _receiver = new MsgBroadcasrReceiver();
     RegisterReceiver(_receiver, filter);
     
 }
예제 #9
0
        protected override void OnResume()
        {
            base.OnResume();
            IntentFilter filter = new IntentFilter(ScanReceiver.IntentAction);

            filter.AddCategory(ScanReceiver.IntentCategory);
            Android.App.Application.Context.RegisterReceiver(_broadcastReceiver, filter);
        }
예제 #10
0
        private void RegisterBroadcastReceiver()
        {
            IntentFilter filter = new IntentFilter(Configurations.LocationUpdated);

            filter.AddCategory(Intent.CategoryDefault);
            _receiver = new BroadCastHandler.MyBroadcastReceiver();
            RegisterReceiver(_receiver, filter);
        }
예제 #11
0
        /// <summary>
        /// Registers <see cref="ListenerBroadcastReceiver"/> in the application.
        /// </summary>
        private void RegisterBroadcastReceiver()
        {
            IntentFilter filter = new IntentFilter(ListenerBroadcastReceiver.LOG_OUTPUT);

            filter.AddCategory(Intent.CategoryDefault);
            receiver = new ListenerBroadcastReceiver(this);
            RegisterReceiver(receiver, filter);
        }
예제 #12
0
        private void RegisterBroadcastReceiver()
        {
            broadcastReceiverRegistered = true;
            IntentFilter filter = new IntentFilter(BackgroundService.LocationBroadcastReceiver.LOCATION_CHANGED);

            filter.AddCategory(Intent.CategoryDefault);
            broadcastReceiver = new BackgroundService.LocationBroadcastReceiver();
            RegisterReceiver(broadcastReceiver, filter);
        }
예제 #13
0
        private void RegisterBootReceiver()
        {
            IntentFilter filter = new IntentFilter(TrackingServiceBootReceiver.logTag);

            filter.AddCategory(Intent.CategoryDefault);
            _receiver = new TrackingServiceBootReceiver();
            RegisterReceiver(_receiver, filter);
            Log.Info(logTag, "TrackingServiceBootReceiver");
        }
예제 #14
0
        /// <summary>
        /// Registers the broadcast receiver.
        /// </summary>
        private void RegisterGPSBroadcastReceiver()
        {
            IntentFilter filter = new IntentFilter(GPSServiceReceiver.LOCATION_UPDATED);

            filter.AddCategory(Intent.CategoryDefault);
            _receiver = new GPSServiceReceiver(this);
            RegisterReceiver(_receiver, filter);
            Log.WriteLine(LogPriority.Debug, TAG, "RegisterBroadcastReceiver");
        }
 protected override void OnResume()
 {
     base.OnResume();
     // Register dynamically decode wedge intent broadcast receiver.
     receiver = new DecodeWedgeIntentReceiver();
     filter   = new IntentFilter();
     filter.AddAction(ACTION_BROADCAST_RECEIVER);
     filter.AddCategory(CATEGORY_BROADCAST_RECEIVER);
     RegisterReceiver(receiver, filter);
 }
        protected override void OnResume()
        {
            base.OnResume();
            IntentFilter myFilter = new IntentFilter();

            myFilter.AddAction(mIntentAction);
            myFilter.AddCategory(mIntentCategory);
            this.ApplicationContext.RegisterReceiver(mMessageReceiver, myFilter);
            mScrollDownHandler = new Handler(Looper.MainLooper);
        }
예제 #17
0
        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();
            }
        }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            TabLayoutResource = Resource.Layout.Tabbar;
            ToolbarResource   = Resource.Layout.Toolbar;

            base.OnCreate(savedInstanceState);
            global::Xamarin.Forms.Forms.Init(this, savedInstanceState);
            LoadApplication(new App());

            _broadcastIntentFilter.AddCategory(Intent.CategoryDefault); // For using broadcast
        }
예제 #19
0
        protected override void OnResume()
        {
            base.OnResume();

            if (null != _broadcastReceiver)
            {
                // Register the broadcast receiver
                IntentFilter filter = new IntentFilter(DataWedgeReceiver.IntentAction);
                filter.AddCategory(DataWedgeReceiver.IntentCategory);
                Android.App.Application.Context.RegisterReceiver(_broadcastReceiver, filter);
            }
        }
예제 #20
0
        protected override void OnCreate(Bundle bundle)
        {
            config = ConfigFile.InitializeConfig();

            base.OnCreate(bundle);

            //Intent i = new Intent();
            //i.SetAction(DATAWEDGE_API_ACTION);
            //i.PutExtra("com.symbol.datawedge.api.ENABLE_DATAWEDGE", true);
            //this.SendBroadcast(i);

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

            var webView = FindViewById <WebView>(Resource.Id.webView);

            webView.Settings.JavaScriptEnabled = true;
            webView.Settings.SaveFormData      = false;

            // Use subclassed WebViewClient to intercept hybrid native calls

            HybridWebViewClient hybridWebViewClient = new HybridWebViewClient();

            hybridWebViewClient.initDefaultProfileHandler += new OnInitDefaultProfileHandler(InitDefaultProfile);
            hybridWebViewClient.sentInputCommandHandler   += new OnSentInputCommandHandler(SendInputCommand);

            webView.SetWebViewClient(hybridWebViewClient);

            inputCommandsCollection = new Dictionary <string, Action <object> >();

            inputCommandsCollection.Add("multibarcode", (param) => callBarcodeScan(param));
            var template = new Test();
            var page     = template.GenerateString();

            // Load the rendered HTML into the view with a base URL
            // that points to the root of the bundled Assets folder
            //webView.LoadDataWithBaseURL("file:///android_asset/", page, "text/html", "UTF-8", null);
            //webView.LoadDataWithBaseURL(Android.Net.Uri.Parse(@"/sdcard/www/index.html").ToString(), page, "text/html", "UTF-8", null);
            //webView.LoadUrl("file:///android_asset/Test.html");
            webView.LoadUrl(config.Url);
            webView.KeyPress += WebView_KeyPress;
            //webView.LoadUrl("file:///android_asset/PaginaBarCode.htm");
            //webView.LoadUrl("file:///storage/sdcard0/www/index.html");
            //registerReceivers();

            IntentFilter filter = new IntentFilter();

            filter.AddAction("com.symbol.datawedge.api.RESULT_ACTION");
            filter.AddCategory("android.intent.category.DEFAULT");

            sampleReceiver = new SampleReceiver();
            RegisterReceiver(sampleReceiver, filter);
        }
예제 #21
0
 private void RegisterBroadcastReceiver()
 {
     try
     {
         IntentFilter filter = new IntentFilter(GPSBackgroundServiceReciever.LOCATION_UPDATED);
         filter.AddCategory(Intent.CategoryDefault);
         _receiver = new GPSBackgroundServiceReciever();
         RegisterReceiver(_receiver, filter);
     }
     catch (Exception ex)
     {
         var err = ex.Message;
     }
 }
예제 #22
0
        public void Enable()
        {
            _context = Application.Context;

            if ((null != _broadcastReceiver) && (null != _context))
            {
                // Register the broadcast receiver
                IntentFilter filter = new IntentFilter(DataWedgeReceiver.IntentAction);
                filter.AddCategory(DataWedgeReceiver.IntentCategory);
                _context.RegisterReceiver(_broadcastReceiver, filter);
                _bRegistered = true;
            }

            EnableProfile();
        }
예제 #23
0
        public override void OnCreate()
        {
            base.OnCreate();

            _context = ApplicationContext; // TODO: Probably creates a memory leak.
            BootstrapApp();

            // Set player plugin directory path
            ApplicationInfo appInfo = PackageManager.GetApplicationInfo(PackageName, 0);
            Sessions.Player.Player.PluginDirectoryPath = appInfo.NativeLibraryDir;

            try
            {
                Console.WriteLine("Application - Registering ConnectionChangeReceiver...");
                _connectionChangeReceiver = new ConnectionChangeReceiver();
                IntentFilter filter = new IntentFilter("android.net.conn.CONNECTIVITY_CHANGE");
                filter.AddCategory(Intent.CategoryDefault);
                RegisterReceiver(_connectionChangeReceiver, filter);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Application - Error: Failed to setup connection change receiver! {0}", ex);
            }

            try
            {
                Console.WriteLine("Application - Registering LockReceiver...");
                var intentFilter = new IntentFilter();
                intentFilter.AddAction(Intent.ActionScreenOff);
                intentFilter.AddAction(Intent.ActionScreenOn);
                intentFilter.AddAction(Intent.ActionUserPresent);
                intentFilter.AddCategory(Intent.CategoryDefault);
                _lockReceiver = new LockReceiver();
                RegisterReceiver(_lockReceiver, intentFilter);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Application - Error: Failed to setup lock receiver! {0}", ex);
            }

//#if __ANDROID_16__
//            if (((int)global::Android.OS.Build.VERSION.SdkInt) >= 16) {
//                _discoveryService = new AndroidDiscoveryService();
//                _discoveryService.StartDiscovery();
//                _discoveryService.DiscoverPeers();
//            }
//#endif
        }
예제 #24
0
        static void SetRetryBroadcastReceiver(Context context)
        {
            if (sRetryReceiver == null)
            {
                sRetryReceiver = new GCMBroadcastReceiver();
                var category = context.PackageName;

                var filter = new IntentFilter(GCMConstants.INTENT_FROM_GCM_LIBRARY_RETRY);
                filter.AddCategory(category);

                var permission = category + ".permission.C2D_MESSAGE";

                Log.Verbose(TAG, "Registering receiver");

                context.RegisterReceiver(sRetryReceiver, filter, permission, null);
            }
        }
예제 #25
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

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

            EMDKResults result = EMDKManager.GetEMDKManager(Application.Context, this);

            if (result.StatusCode != EMDKResults.STATUS_CODE.Success)
            {
                Toast.MakeText(this, "Error opening the EMDK Manager", ToastLength.Long).Show();
            }
            else
            {
                Toast.MakeText(this, "EMDK Manager is available", ToastLength.Long).Show();
            }

            // Get our button from the layout resource,
            // and attach an event to toggle scanning option
            Button scanButton = FindViewById <Button>(Resource.Id.btn_scan);

            scanButton.Click += delegate
            {
                var intent = new Intent();
                intent.SetAction(ACTION_SOFTSCANTRIGGER);
                intent.PutExtra(EXTRA_PARAM, DWAPI_TOGGLE_SCANNING);
                SendBroadcast(intent);
            };

            MyReceiver _broadcastReceiver = new MyReceiver();

            EditText editText = FindViewById <EditText>(Resource.Id.editbox);

            _broadcastReceiver.scanDataReceived += (s, scanData) =>
            {
                editText.Text = scanData;
            };

            // Register the broadcast receiver
            IntentFilter filter = new IntentFilter("barcodescanner.RECVR");

            filter.AddCategory("android.intent.category.DEFAULT");
            Application.Context.RegisterReceiver(_broadcastReceiver, filter);
        }
예제 #26
0
        static SampleMediaRouteProvider()
        {
            IntentFilter f1 = new IntentFilter();

            f1.AddCategory(CATEGORY_SAMPLE_ROUTE);
            f1.AddAction(ACTION_GET_STATISTICS);

            IntentFilter f2 = new IntentFilter();

            f2.AddCategory(MediaControlIntent.CategoryRemotePlayback);
            f2.AddAction(MediaControlIntent.ActionPlay);
            f2.AddDataScheme("http");
            f2.AddDataScheme("https");
            addDataTypeUnchecked(f2, "video/*");

            CONTROL_FILTERS = new List <IntentFilter> ();
            CONTROL_FILTERS.Add(f1);
            CONTROL_FILTERS.Add(f2);
        }
예제 #27
0
 protected override void OnResume()
 {
     base.OnResume();
     try
     {
         if (_isNFCCapable)
         {
             var pendingIntent    = PendingIntent.GetActivity(this, 0, new Intent(this, typeof(MainActivity)).AddFlags(ActivityFlags.SingleTop), 0);
             var intentFilterNdef = new IntentFilter(NfcAdapter.ActionNdefDiscovered);
             var intentFilterTag  = new IntentFilter(NfcAdapter.ActionTagDiscovered);
             intentFilterNdef.AddCategory(Intent.CategoryDefault);
             intentFilterTag.AddCategory(Intent.CategoryDefault);
             var        intentFilters = new IntentFilter[] { intentFilterNdef, intentFilterTag };
             string[][] techLists     = new string[][] { new string[] { typeof(Ndef).Name, typeof(NdefFormatable).Name } };
             ((NfcAdapter)CrossNFCReaderFeature.Current.Adapter)?.EnableForegroundDispatch(this, pendingIntent, intentFilters, techLists);
         }
     }
     catch { }
 }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.activity_item_detail);
            var toolbar = FindViewById <Toolbar>(Resource.Id.detail_toolbar);

            SetSupportActionBar(toolbar);

            // Show the Up button in the action bar.
            SupportActionBar?.SetDisplayHomeAsUpEnabled(true);

            // savedInstanceState is non-null when there is fragment state
            // saved from previous configurations of this activity
            // (e.g. when rotating the screen from portrait to landscape).
            // In this case, the fragment will automatically be re-added
            // to its container so we don't need to manually add it.
            // For more information, see the Fragments API guide at:
            //
            // http://developer.android.com/guide/components/fragments.html
            //
            if (savedInstanceState == null)
            {
                // Create the detail fragment and add it to the activity
                // using a fragment transaction.
                Bundle arguments = new Bundle();
                arguments.PutString(ItemDetailFragment.ArgItemId,
                                    Intent.GetStringExtra(ItemDetailFragment.ArgItemId));
                ItemDetailFragment fragment = new ItemDetailFragment
                {
                    Arguments = arguments
                };
                SupportFragmentManager.BeginTransaction()
                .Add(Resource.Id.item_detail_container, fragment)
                .Commit();
            }
            IntentFilter filter = new IntentFilter();

            filter.AddCategory(Intent.CategoryDefault);
            filter.AddAction(Resources.GetString(Resource.String.activity_intent_filter_action));
            RegisterReceiver(_broadcastReceiver, filter);
        }
예제 #29
0
        public AndroidNotifier()
        {
            _notificationManager = Application.Context.GetSystemService(global::Android.Content.Context.NotificationService) as NotificationManager;

            // register the notification action receiver
            _foregroundServiceNotificationActionReceiver = new ForegroundServiceNotificationActionReceiver();
            IntentFilter foregroundServiceNotificationActionIntentFilter = new IntentFilter();

            foregroundServiceNotificationActionIntentFilter.AddAction(FOREGROUND_SERVICE_NOTIFICATION_ACTION_PAUSE);
            foregroundServiceNotificationActionIntentFilter.AddAction(FOREGROUND_SERVICE_NOTIFICATION_ACTION_RESUME);
            foregroundServiceNotificationActionIntentFilter.AddCategory(Intent.CategoryDefault);
            Application.Context.RegisterReceiver(_foregroundServiceNotificationActionReceiver, foregroundServiceNotificationActionIntentFilter);

            // create notification builder for the foreground service and set initial content
            PendingIntent mainActivityPendingIntent = PendingIntent.GetActivity(Application.Context, 0, new Intent(Application.Context, typeof(AndroidMainActivity)), 0);

            _foregroundServiceNotificationBuilder = CreateNotificationBuilder(AndroidNotifier.SensusNotificationChannel.ForegroundService)
                                                    .SetSmallIcon(Resource.Drawable.ic_launcher)
                                                    .SetContentIntent(mainActivityPendingIntent)
                                                    .SetOngoing(true);
        }
        /*
         * learning from
         * http://blog.csdn.net/earbao/article/details/50961713
         */
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

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

            // Get our button from the layout resource,
            // and attach an event to it
            Button button = FindViewById <Button>(Resource.Id.ScanButton);

            button.Click += Scan;;

            var writerButton = FindViewById <Button>(Resource.Id.WriteButton);

            writerButton.Click += Write;

            var label = FindViewById <TextView>(Resource.Id.ResultLabel);

            nfcAdapter = NfcAdapter.GetDefaultAdapter(ApplicationContext);
            if (nfcAdapter == null)
            {
                label.Text = "NFC is not available.";
                return;
            }

            if (!nfcAdapter.IsEnabled)
            {
                label.Text = "NFC is disabled.";
                return;
            }

            //nfcAdapter.SetNdefPushMessageCallback(this, this);
            var intent = new Intent(this, this.Class);

            intent.AddFlags(ActivityFlags.SingleTop);
            nfcPi     = PendingIntent.GetActivity(this, 0, intent, 0);
            nfcFilter = new IntentFilter(NfcAdapter.ActionNdefDiscovered);
            nfcFilter.AddCategory(Intent.CategoryDefault);
        }
예제 #31
0
        protected override void OnResume()
        {
            base.OnResume();
            // read preferences
            ISharedPreferences sharedPref = PreferenceManager.GetDefaultSharedPreferences(this);

            scanTech = sharedPref.GetString(KEY_PREF_SCAN_TECHNOLOGY, VALUE_PREF_SCAN_NONE);
            if (scanTech == VALUE_PREF_SCAN_NONE)
            {
                Snackbar.Make(FindViewById(Resource.Id.fab),
                              "Please select scanning technology!", Snackbar.LengthLong)
                .SetAction(Resource.String.action_settings, view =>
                {
                    Intent intent = new Intent(view.Context, typeof(SettingsActivity));
                    intent.PutExtra(PreferenceActivity.ExtraShowFragment,
                                    // typeof(SettingsActivity.ScannerPreferenceFragment).Name
                                    "TechStoreX.SettingsActivity.ScannerPreferenceFragment");
                    intent.PutExtra(PreferenceActivity.ExtraNoHeaders, true);
                    StartActivity(intent);
                }).Show();
            }
            //if (useDataWedge) {
            else if (scanTech == VALUE_PREF_SCAN_DATAWEDGE)
            {
                //Register for the intent to receive the scanned data using intent callback.
                //The action and category name used must be same as the names used in the profile creation.
                IntentFilter filter = new IntentFilter();
                filter.AddAction(PackageName + ".SCAN");
                filter.AddCategory(Intent.CategoryDefault);
                RegisterReceiver(receiver, filter);
            }
            // check permissions in runtime
            if ((int)Android.OS.Build.VERSION.SdkInt >= 23)
            {
                RequestPermissions();
            }
            // set up logout timer
            logoutTime = int.Parse(sharedPref.GetString(KEY_PREF_TIMEOUT, VALUE_PREF_TIMEOUT_DEFAULT));
            LogoutTimerUtility.StartLogoutTimer(this, this, logoutTime);
        }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.activity_item_list);

            if (_content == null)
            {
                _content = new APIContent();
            }
            else
            {
                _content.Clear();
            }
            _content.AddItem(GetString(Resource.String.create_barcode), GetString(Resource.String.create_barcode_details), Resource.Drawable.ic_createbarcode);
            _content.AddItem(GetString(Resource.String.fda_recall), GetString(Resource.String.fda_recall_details), Resource.Drawable.ic_fdarecall);
            _content.AddItem(GetString(Resource.String.upc_lookup), GetString(Resource.String.upc_lookup_details), Resource.Drawable.ic_upclookup);

            var toolbar = FindViewById <AndroidX.AppCompat.Widget.Toolbar>(Resource.Id.toolbar);

            SetSupportActionBar(toolbar);
            toolbar.Title = Title;

            if (FindViewById(Resource.Id.item_detail_container) != null)
            {
                // The detail container view will be present only in the
                // large-screen layouts (res/values-w900dp).
                // If this view is present, then the
                // activity should be in two-pane mode.
                _twoPane = true;
            }

            View recyclerView = FindViewById(Resource.Id.item_list);

            SetupRecyclerView((RecyclerView)recyclerView);
            IntentFilter filter = new IntentFilter();

            filter.AddCategory(Intent.CategoryDefault);
            filter.AddAction(Resources.GetString(Resource.String.activity_intent_filter_action));
            RegisterReceiver(_broadcastReceiver, filter);
        }
        protected virtual void Execute(DWSettings settings, Action <CommandBaseResults> callback)
        {
            /*
             * Launch timeout mechanism
             */
            base.Execute(settings);

            /*
             * Setup callback
             */
            mCommandBaseCallback = callback;

            IntentFilter intentFilter = new IntentFilter();

            intentFilter.AddAction(DataWedgeConstants.ACTION_RESULT_DATAWEDGE_FROM_6_2);
            intentFilter.AddCategory(Intent.CategoryDefault);

            /*
             * Register receiver for resutls
             */
            mContext.ApplicationContext.RegisterReceiver(mBroadcastReceiver, intentFilter);
        }
예제 #34
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

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

            EMDKResults result = EMDKManager.GetEMDKManager(Application.Context, this);

            if (result.StatusCode != EMDKResults.STATUS_CODE.Success)
            {
                Toast.MakeText(this, "Error opening the EMDK Manager", ToastLength.Long).Show();
            }
            else
            {
                Toast.MakeText(this, "EMDK Manager is available", ToastLength.Long).Show();
            }

            // Get our button from the layout resource,
            // and attach an event to toggle scanning option
            Button scanButton = FindViewById<Button>(Resource.Id.btn_scan);

            scanButton.Click += delegate
            {
                var intent = new Intent();
                intent.SetAction(ACTION_SOFTSCANTRIGGER);
                intent.PutExtra(EXTRA_PARAM, DWAPI_TOGGLE_SCANNING);
                SendBroadcast(intent);
            };

            MyReceiver _broadcastReceiver = new MyReceiver();

            EditText editText = FindViewById<EditText>(Resource.Id.editbox);

            _broadcastReceiver.scanDataReceived += (s, scanData) =>
            {
                editText.Text = scanData;
            };

            // Register the broadcast receiver
            IntentFilter filter = new IntentFilter("barcodescanner.RECVR");
            filter.AddCategory("android.intent.category.DEFAULT");
            Application.Context.RegisterReceiver(_broadcastReceiver, filter);
        }
예제 #35
0
		static void SetRetryBroadcastReceiver(Context context)
		{
			if (sRetryReceiver == null)
			{
				sRetryReceiver = new GCMBroadcastReceiver();
				var category = context.PackageName;

				var filter = new IntentFilter(GCMConstants.INTENT_FROM_GCM_LIBRARY_RETRY);
				filter.AddCategory(category);

				var permission = category + ".permission.C2D_MESSAGE";

				Log.Verbose(TAG, "Registering receiver");

				context.RegisterReceiver(sRetryReceiver, filter, permission, null);
			}
		}
예제 #36
0
 /// <summary>
 /// 
 /// </summary>
 protected override void OnResume()
 {
     //Register custom receiver  
     try
     {
         base.OnResume();
         IntentFilter filter = new IntentFilter(MyLocationReceiver.GRID_STARTED);
         filter.AddCategory(Intent.CategoryDefault);
         _receiver = new MyLocationReceiver(this);
         RegisterReceiver(_receiver, filter);
     }
     catch (Exception ex)
     {
          Toast.MakeText(Application.Context, "GetLocation-OnResume" + ex.Message, ToastLength.Long).Show();
     }
 }