コード例 #1
0
        private static void ConfigureFlutnetRuntime()
        {
            try
            {
                FlutnetRuntime.Init("TRIAL-APP-KEY");
                FlutnetRuntime.RegisterPlatformService(new ContactService(), "contact_service");
                Initialized = true;
            }
            catch (Exception e)
            {
                if (CurrentActivity != null)
                {
                    AlertDialog.Builder builder = new AlertDialog.Builder(CurrentActivity);
                    builder.SetTitle("Fatal Error");
                    builder.SetMessage(e.Message);
                    builder.SetCancelable(false);
                    builder.SetPositiveButton("OK", (sender, args) =>
                    {
                        Process.KillProcess(Process.MyPid());
                        Environment.Exit(0);
                    });

                    AlertDialog dialog = builder.Create();
                    dialog.Show();
                }
                else
                {
                    throw;
                }
            }
        }
コード例 #2
0
        public override async void ViewDidAppear(bool animated)
        {
            base.ViewDidAppear(animated);

            if (_initialized)
            {
                return;
            }

            // Connect Flutter plugins (uncomment only if Flutter module uses plugins)
            //FlutnetContactList.PluginInterop.GeneratedPluginRegistrant.Register(this.Engine);

            try
            {
                FlutnetRuntime.Init("TRIAL-APP-KEY");
                FlutnetRuntime.RegisterPlatformService(new ContactService(), "contact_service");

                // Initialize the bridge
#if (DEBUG)
                _bridge = new FlutnetBridge(this.Engine, FlutnetBridgeMode.PlatformChannel);
#else
                _bridge = new FlutnetBridge(this.Engine);
#endif
                _initialized = true;
            }
            catch (Exception e)
            {
                var taskCompletionSource = new TaskCompletionSource <bool>();
                var alert = UIAlertController.Create("Fatal Error", e.Message, UIAlertControllerStyle.Alert);
                alert.AddAction(UIAlertAction.Create("OK", UIAlertActionStyle.Default, a => taskCompletionSource.SetResult(true)));
                this.PresentViewController(alert, true, null);
                await taskCompletionSource.Task;
                throw;
            }
        }
コード例 #3
0
        public override async void ViewDidAppear(bool animated)
        {
            base.ViewDidAppear(animated);

            if (_initialized)
            {
                return;
            }

            try
            {
                FlutnetRuntime.Init();
                FlutnetRuntime.RegisterPlatformService(new CounterService(), "counter_service");
#if DEBUG
                _bridge = new FlutnetBridge(this.Engine, FlutnetBridgeMode.PlatformChannel);
#else
                _bridge = new FlutnetBridge(this.Engine);
#endif
                _initialized = true;
            }
            catch (Exception e)
            {
                var tcs   = new TaskCompletionSource <bool>();
                var alert = UIAlertController.Create("Fatal Error", e.Message, UIAlertControllerStyle.Alert);
                alert.AddAction(UIAlertAction.Create("OK", UIAlertActionStyle.Default, a => tcs.SetResult(true)));
                this.PresentViewController(alert, true, null);
                await tcs.Task;
                throw;
            }
        }
コード例 #4
0
        public override async void ViewDidAppear(bool animated)
        {
            base.ViewDidAppear(animated);

            if (_initialized)
            {
                return;
            }

            // Connect Flutter plugins (uncomment only if Flutter module uses plugins)
            //FlutnetNotes.PluginInterop.GeneratedPluginRegistrant.Register(this.Engine);

            try
            {
                //
                // Init the runtime using the application key (generated from the flutnet console)
                //
                FlutnetRuntime.Init("TRIAL-APP-KEY");

                //
                // Launcher Service
                //
                FlutnetRuntime.RegisterPlatformService(new LauncherService(), "launcher_service");

                //
                // Preference Service
                //
                FlutnetRuntime.RegisterPlatformService(new PreferenceService(), "preference_service");

                //
                // Notes Database
                //
                NoteDatabase noteDatabase = new NoteDatabase(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "Notes.db3"));

                FlutnetRuntime.RegisterPlatformService(noteDatabase, "note_database");

                // Initialize the bridge
#if (DEBUG)
                _bridge = new FlutnetBridge(this.Engine, FlutnetBridgeMode.PlatformChannel);
#else
                _bridge = new FlutnetBridge(this.Engine);
#endif
                _initialized = true;
            }
            catch (Exception e)
            {
                var taskCompletionSource = new TaskCompletionSource <bool>();
                var alert = UIAlertController.Create("Fatal Error", e.Message, UIAlertControllerStyle.Alert);
                alert.AddAction(UIAlertAction.Create("OK", UIAlertActionStyle.Default, a => taskCompletionSource.SetResult(true)));
                this.PresentViewController(alert, true, null);
                await taskCompletionSource.Task;
                throw;
            }
        }
コード例 #5
0
        private static void ConfigureFlutnetRuntime()
        {
            try
            {
                //
                // Init the runtime using the application key (generated from the flutnet console)
                //
                FlutnetRuntime.Init("TRIAL-APP-KEY");

                //
                // Launcher Service
                //
                FlutnetRuntime.RegisterPlatformService(new LauncherService(), "launcher_service");

                //
                // Preference Service
                //
                FlutnetRuntime.RegisterPlatformService(new PreferenceService(), "preference_service");

                //
                // Notes Database
                //
                NoteDatabase noteDatabase = new NoteDatabase(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "Notes.db3"));

                FlutnetRuntime.RegisterPlatformService(noteDatabase, "note_database");

                Initialized = true;
            }
            catch (Exception e)
            {
                if (CurrentActivity != null)
                {
                    AlertDialog.Builder builder = new AlertDialog.Builder(CurrentActivity);
                    builder.SetTitle("Fatal Error");
                    builder.SetMessage(e.Message);
                    builder.SetCancelable(false);
                    builder.SetPositiveButton("OK", (sender, args) =>
                    {
                        Process.KillProcess(Process.MyPid());
                        Environment.Exit(0);
                    });

                    AlertDialog dialog = builder.Create();
                    dialog.Show();
                }
                else
                {
                    throw;
                }
            }
        }
コード例 #6
0
        public override void ConfigureFlutterEngine(FlutterEngine flutterEngine)
        {
            base.ConfigureFlutterEngine(flutterEngine);

            FlutnetRuntime.RegisterPlatformService(new ThermometerServiceDroid((UsbManager)GetSystemService(UsbService), Context), "thermometer_service");

            // Connect Flutter plugins (uncomment only if Flutter module uses plugins)
            //Flutnet.Interop.Plugins.GeneratedPluginRegistrant.RegisterWith(flutterEngine);

            if (App.Initialized)
            {
                App.ConfigureFlutnetBridge(this.FlutterEngine);
            }
        }
コード例 #7
0
        private static void ConfigureFlutnetRuntime()
        {
            try
            {
                //
                // Set the runtime using your Application KEY: the trial version has 100 native calls limit
                //
                FlutnetRuntime.Init("TRIAL-APP-KEY");

                //
                // Register the USB service in the flutnet runtime
                //
                FlutnetRuntime.RegisterPlatformService(new ThermometerServiceDroid((UsbManager)AppContext.GetSystemService(Context.UsbService), AppContext), "thermometer_service");

                Initialized = true;
            }
            catch (Exception e)
            {
                if (CurrentActivity != null)
                {
                    AlertDialog.Builder builder = new AlertDialog.Builder(CurrentActivity);
                    builder.SetTitle("Fatal Error");
                    builder.SetMessage(e.Message);
                    builder.SetCancelable(false);
                    builder.SetPositiveButton("OK", (sender, args) =>
                    {
                        Android.OS.Process.KillProcess(Android.OS.Process.MyPid());
                        Environment.Exit(0);
                    });

                    AlertDialog dialog = builder.Create();
                    dialog.Show();
                }
                else
                {
                    throw;
                }
            }
        }
コード例 #8
0
        private static void ConfigureFlutnetRuntime()
        {
            try
            {
                //
                // Init the runtime using the application key (generated from the flutnet console)
                //
                FlutnetRuntime.Init("TRIAL-APP-KEY");

                //
                // Register the service on the flutnet runtime
                //
                FlutnetRuntime.RegisterPlatformService(new Service1(), "my_service");
                Initialized = true;
            }
            catch (Exception e)
            {
                if (CurrentActivity != null)
                {
                    AlertDialog.Builder builder = new AlertDialog.Builder(CurrentActivity);
                    builder.SetTitle("Fatal Error");
                    builder.SetMessage(e.Message);
                    builder.SetCancelable(false);
                    builder.SetPositiveButton("OK", (sender, args) =>
                    {
                        Process.KillProcess(Process.MyPid());
                        Environment.Exit(0);
                    });

                    AlertDialog dialog = builder.Create();
                    dialog.Show();
                }
                else
                {
                    throw;
                }
            }
        }