Пример #1
0
        protected override void OnActivityResult(int requestCode, Result resultCode, Intent data)
        {
            // TODO Auto-generated method stub

            if (requestCode == RESPONCERESULT && resultCode == Result.Ok)
            {
                IList <string> results      = data.GetStringArrayListExtra(RecognizerIntent.ExtraResults); //Get a result array list
                string         resultString = "";

                for (int i = 0; i < results.Count; i++)
                {
                    resultString = results[i];  //Transform the array list into a string
                }
                vtext.Append(resultString + "/" + StringURL.REG_W(resultString));
                vtext.Append("\n");
            }
            base.OnActivityResult(requestCode, resultCode, data);
        }
Пример #2
0
        protected override void OnActivityResult(int requestCode, Result resultCode, Intent data)
        {
            // TODO Auto-generated method stub

            if (requestCode == RESPONCERESULT && resultCode == Result.Ok)
            {
                IList <string> results      = data.GetStringArrayListExtra(RecognizerIntent.ExtraResults);
                string         resultString = "";

                for (int i = 0; i < results.Count; i++)
                {
                    resultString = results[i];
                }
                vt.Append(resultString + "\n");
                cv.Append(SocketClient.send(resultString + "/" + StringURL.REG_W(resultString)));   //Send the results to the server
                //cv.Append(SocketClient.receive() + "\n");   //Receive data from server
            }
            base.OnActivityResult(requestCode, resultCode, data);
        }
Пример #3
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            // Create your application here
            SetContentView(Resource.Layout.Connection_layout);

            EditText ip   = FindViewById <EditText>(Resource.Id.IpAddress);
            EditText port = FindViewById <EditText>(Resource.Id.port);

            vt = FindViewById <TextView>(Resource.Id.voicetestview);
            cv = FindViewById <TextView>(Resource.Id.connectionview);

            sp  = FindViewById <Button>(Resource.Id.speakC);
            sub = FindViewById <Button>(Resource.Id.submitC);
            can = FindViewById <Button>(Resource.Id.cancelC);
            set = FindViewById <Button>(Resource.Id.settingC);

            can.Enabled = false;
            sp.Enabled  = false;

            sub.Click += (object sender, EventArgs e) =>
            {
                if (StringURL.isEmpty(ip.Text) || StringURL.isEmpty(port.Text)) //Determine whether the IP address and the port are empty
                {
                    cv.Append("Please input IP address and port.\n");
                }
                else if (SocketClient.clientSocket != null && SocketClient.clientSocket.Connected == true)  //Determine whether the client connects to server
                {
                    cv.Append("Already Connected.\n");
                }
                else
                {
                    can.Enabled = true;
                    sp.Enabled  = true;
                    sub.Enabled = false;
                    cv.Append("Connection in process.\n");
                    cv.Append(SocketClient.SocketConnect(ip.Text, Convert.ToInt32(port.Text))); //Connect to server
                    //cv.Append(SocketClient.receive() + "\n");   //Receive data from server
                }
            };

            can.Click += (object sender, EventArgs e) =>
            {
                cv.Append(SocketClient.disconnect() + "\n");
                can.Enabled = false;
                sp.Enabled  = false;
                sub.Enabled = true;
            };

            sp.Click += (object sender, EventArgs e) =>
            {
                speak();
            };

            set.Click += (object sender, EventArgs e) =>
            {
                Intent setIntent = new Intent(this, typeof(Setting));
                StartActivity(setIntent);
            };
        }