コード例 #1
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            SetContentView(Resource.Layout.Main);

            var BtnStartSpeech = FindViewById <Button>(Resource.Id.btn_start_speech);

            BtnStartSpeech.Click += BtnStartSpeech_Click;

            var recListener = new RecognitionListener();

            recListener.BeginSpeech += RecListener_BeginSpeech;
            recListener.EndSpeech   += RecListener_EndSpeech;
            recListener.Error       += RecListener_Error;
            recListener.Ready       += RecListener_Ready;
            recListener.Recognized  += RecListener_Recognized;

            Recognizer = SpeechRecognizer.CreateSpeechRecognizer(this);
            Recognizer.SetRecognitionListener(recListener);

            SpeechIntent = new Intent(RecognizerIntent.ActionRecognizeSpeech);
            SpeechIntent.PutExtra(RecognizerIntent.ExtraLanguageModel, RecognizerIntent.LanguageModelFreeForm);
            SpeechIntent.PutExtra(RecognizerIntent.ExtraCallingPackage, PackageName);
        }
コード例 #2
0
ファイル: Recognizer.cs プロジェクト: Geeksltd/Zebble.Speech
            public static async Task Stop()
            {
                VoiceIntent?.Dispose();
                VoiceIntent = null;

                AndroidRecognizer?.SetRecognitionListener(null);

                try
                {
                    AndroidRecognizer?.Destroy();
                    AndroidRecognizer?.Dispose();
                }
                catch (Exception ex)
                {
                    await Alert.Toast("Speech recognition error: " + ex.Message);
                }

                AndroidRecognizer = null;
                StandardListener?.Dispose();
                StandardListener = null;

                IsStopped = true;

                Stopped?.Invoke();
            }
コード例 #3
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            SetContentView(Resource.Layout.Main);

            var BtnStartSpeech = FindViewById <Android.Widget.Button>(Resource.Id.btn_start_game);

            BtnStartSpeech.Click += BtnStartSpeech_Click;

            var recListener = new RecognitionListener();

            recListener.BeginSpeech += RecListener_BeginSpeech;
            recListener.EndSpeech   += RecListener_EndSpeech;
            recListener.Error       += RecListener_Error;
            recListener.Ready       += RecListener_Ready;
            recListener.Recognized  += RecListener_Recognized;

            Recognizer = SpeechRecognizer.CreateSpeechRecognizer(this);
            Recognizer.SetRecognitionListener(recListener);

            SpeechIntent = new Intent(RecognizerIntent.ActionRecognizeSpeech);
            SpeechIntent.PutExtra(RecognizerIntent.ExtraLanguageModel, RecognizerIntent.LanguageModelFreeForm);
            SpeechIntent.PutExtra(RecognizerIntent.ExtraCallingPackage, PackageName);

            //Debug Button
            //var BtnEndSpeech = FindViewById<Android.Widget.Button>(Resource.Id.btn_end_speech);
            //BtnEndSpeech.Click += BtnEndSpeech_Click;
            //BtnEndSpeech.Visibility = Android.Views.ViewStates.Invisible;

            var BtnGetOut = FindViewById <Android.Widget.Button>(Resource.Id.btn_GetOut);

            BtnGetOut.Click += BtnGetOut_Click;
            var BtnClearOut = FindViewById <Android.Widget.Button>(Resource.Id.btn_Clear);

            BtnClearOut.Click += BtnClearOut_Click;

            var txtYourScore = FindViewById <Android.Widget.EditText>(Resource.Id.YourScore);

            txtYourScore.Click += txtYourScore_Click;

            var BtnSeeOutChart = FindViewById <Android.Widget.Button>(Resource.Id.btn_SeeOutChart);

            BtnSeeOutChart.Click += delegate
            {
                StartActivity(typeof(OutChartActivity));
            };

            Log.Debug(nameof(AndroidActivity), nameof(OnCreate));
            mList.Add("Start");
            Forms.Init(this, savedInstanceState);

            mAudioManager = (AudioManager)GetSystemService(Context.AudioService);
        }
コード例 #4
0
ファイル: Recognizer.cs プロジェクト: Geeksltd/Zebble.Speech
            static Task DoStart()
            {
                if (AndroidRecognizer == null)
                {
                    StandardListener  = new RecognitionListener();
                    AndroidRecognizer = SpeechRecognizer.CreateSpeechRecognizer(UIRuntime.NativeRootScreen as AndroidOS.BaseActivity);
                    AndroidRecognizer.SetRecognitionListener(StandardListener);
                    AndroidRecognizer.StartListening(CreateIntent());

                    IsStopped = false;
                }

                return(Task.CompletedTask);
            }
コード例 #5
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            SetContentView(Resource.Layout.NavGame);

            Log.Debug(GetType().FullName, "Activity A - OnCreate");

            turnClassSerial = Intent.GetStringExtra("turnClassSerial");
            System.Diagnostics.Debug.Print("-" + turnClassSerial);
            UIClassSerial = Intent.GetStringExtra("UIClassSerial");
            System.Diagnostics.Debug.Print("-" + UIClassSerial);

            var txtDartScore  = FindViewById <Android.Widget.EditText>(Resource.Id.DartScore);
            var txtStartScore = FindViewById <Android.Widget.EditText>(Resource.Id.StartScore);
            var txtNewOut     = FindViewById <Android.Widget.TextView>(Resource.Id.txtNewScore);
            var txtOutTurn    = FindViewById <Android.Widget.TextView>(Resource.Id.txtOutTurn);

            //Saved Instance Takes precedence
            if (savedInstanceState != null)
            {
                string savedTurn = savedInstanceState.GetString("jsonSerialTurn", "");
                clsTurn = JsonConvert.DeserializeObject <Turn>(savedTurn);

                System.Diagnostics.Debug.Print("-" + clsTurn.CurrentScore.ToString());

                string savedUIState = savedInstanceState.GetString("jsonSerialUIState", "");
                clsUIState = JsonConvert.DeserializeObject <UIState>(savedUIState);

                System.Diagnostics.Debug.Print("-" + clsUIState.LastScore.ToString());

                if (TurnState.InProgress == clsTurn.State)
                {
                    txtDartScore.Text  = clsUIState.LastScore.ToString();
                    txtStartScore.Text = clsTurn.StartingScore.ToString();
                    txtNewOut.Text     = clsUIState.CurrentScoreText.ToString();
                    txtOutTurn.Text    = clsUIState.DoubleOutText.ToString();

                    currentScore = clsTurn.CurrentScore;
                }
                else
                {
                    txtDartScore.Text  = "";
                    txtStartScore.Text = "";
                    txtNewOut.Text     = "";
                    txtOutTurn.Text    = "";

                    currentScore = 0;
                }

                Log.Debug(GetType().FullName, "AndroidNavActivity - Recovered instance state");
            }
            else if (null != turnClassSerial && 0 < turnClassSerial.Trim().Length)
            {
                clsTurn = JsonConvert.DeserializeObject <Turn>(turnClassSerial);

                System.Diagnostics.Debug.Print("-" + clsTurn.CurrentScore.ToString());

                clsUIState = JsonConvert.DeserializeObject <UIState>(UIClassSerial);

                System.Diagnostics.Debug.Print("-" + clsUIState.LastScore.ToString());

                if (TurnState.InProgress == clsTurn.State)
                {
                    txtDartScore.Text  = clsUIState.LastScore.ToString();
                    txtStartScore.Text = clsTurn.StartingScore.ToString();
                    txtNewOut.Text     = clsUIState.CurrentScoreText.ToString();
                    txtOutTurn.Text    = clsUIState.DoubleOutText.ToString();

                    currentScore = clsTurn.CurrentScore;
                }
                else
                {
                    txtDartScore.Text  = "";
                    txtStartScore.Text = "";
                    txtNewOut.Text     = "";
                    txtOutTurn.Text    = "";

                    currentScore = 0;
                }

                Log.Debug(GetType().FullName, "AndroidNavActivity - Loaded Serial");
            }

            var BtnStartSpeech = FindViewById <Android.Widget.Button>(Resource.Id.btn_start_game);

            BtnStartSpeech.Click += BtnStartSpeech_Click;

            var recListener = new RecognitionListener();

            recListener.BeginSpeech += RecListener_BeginSpeech;
            recListener.EndSpeech   += RecListener_EndSpeech;
            recListener.Error       += RecListener_Error;
            recListener.Ready       += RecListener_Ready;
            recListener.Recognized  += RecListener_Recognized;

            Recognizer = SpeechRecognizer.CreateSpeechRecognizer(this);
            Recognizer.SetRecognitionListener(recListener);

            SpeechIntent = new Intent(RecognizerIntent.ActionRecognizeSpeech);
            SpeechIntent.PutExtra(RecognizerIntent.ExtraLanguageModel, RecognizerIntent.LanguageModelFreeForm);
            SpeechIntent.PutExtra(RecognizerIntent.ExtraCallingPackage, PackageName);

            var BtnStartTurn = FindViewById <Android.Widget.Button>(Resource.Id.btn_StartTurn);

            BtnStartTurn.Click += BtnStartTurn_Click;

            var BtnDartScored = FindViewById <Android.Widget.Button>(Resource.Id.btn_DartScored);

            BtnDartScored.Click += BtnDartScored_Click;

            var BtnGetOut = FindViewById <Android.Widget.Button>(Resource.Id.btn_GetOut);

            BtnGetOut.Click += BtnGetOut_Click;
            var BtnClearOut = FindViewById <Android.Widget.Button>(Resource.Id.btn_Clear);

            BtnClearOut.Click += BtnClearOut_Click;

            var txtYourScore = FindViewById <Android.Widget.EditText>(Resource.Id.YourScore);

            txtYourScore.Click += txtYourScore_Click;

            //var BtnSeeOutChart = FindViewById<Android.Widget.Button>(Resource.Id.btn_SeeOutChart);
            //BtnSeeOutChart.Click += delegate {
            //    StartActivity(typeof(OutChartActivity));
            //};

            Log.Debug(nameof(AndroidActivity), nameof(OnCreate));
            mList.Add("Start");
            Forms.Init(this, savedInstanceState);

            mAudioManager = (AudioManager)GetSystemService(Context.AudioService);

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

            if (toolbar != null)
            {
                SetSupportActionBar(toolbar);
                SupportActionBar.SetDisplayHomeAsUpEnabled(false);
                SupportActionBar.SetHomeButtonEnabled(false);
            }

            bottomNavigation = FindViewById <BottomNavigationView>(Resource.Id.bottom_navigation);


            bottomNavigation.NavigationItemSelected += BottomNavigation_NavigationItemSelected;

            try
            {
                bottomNavigation.Menu.GetItem(0).SetChecked(true);
            }
            catch (System.Exception ex)
            {
                System.Diagnostics.Debug.Print("Heya:" + ex.Message);
            }
        }