コード例 #1
0
        private async void SimilarWordsAction()
        {
            Task <Java.Lang.Object> multipleSimilarityWordsTask = analyzer.AnalyseSimilarWordsAsync(et_word_for_simil.Text.ToString(), Int32.Parse(et_num_for_simil.Text.ToString()));

            try
            {
                await multipleSimilarityWordsTask;
                if (multipleSimilarityWordsTask.IsCompleted && multipleSimilarityWordsTask.Result != null)
                {
                    // Analyze success
                    List <string>       words     = new List <string>();
                    Java.Util.ArrayList arrayList = multipleSimilarityWordsTask.Result.JavaCast <Java.Util.ArrayList>();
                    var iterator = arrayList.Iterator();
                    while (iterator.HasNext)
                    {
                        words.Add((string)iterator.Next());
                    }

                    Toast.MakeText(this, "analyse multipleSimilarWords success", ToastLength.Short).Show();
                    JSONArray jsonObject = new JSONArray(words);
                    tv_simil_words.Text = jsonObject.ToString();
                }
                else
                {
                    // Analyze failed
                    Log.Debug(Tag, "Analyze Failed");
                }
            }
            catch (Exception ex)
            {
                //Operation failed
                Log.Error(Tag, ex.Message);
            }
        }