When running my android project in visual studio i'm getting exception what should i do ?

DanielLipDanielLip USMember
edited July 2015 in Xamarin.Android

This is my code trying to use Text To Speech.
I don't see any errors but when i'm running my program I see in visual studio a window:

An unhandled exception occurred I can click on BREAK or CONTINUE
If I click on BREAK I see: Frame not in module

Something is wrong with my code but not sure what and where and how to fix it.

`using System;
using Android.App;
using Android.Content;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using Android.OS;
using Android.Speech.Tts;

namespace App6
{
[Activity(Label = "App6", MainLauncher = true, Icon = "@drawable/icon")]
public class MainActivity : Activity
{
int count = 1;
private static int DATA_CHECK_CODE = 0;
TextToSpeech mTts;
//TextToSpeech.IOnInitListener listen;

    public MainActivity()
    {
       // listen.OnInit(OperationResult.Success);

        initTTS();
    }


    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.MyButton);

        button.Click += delegate { button.Text = string.Format("{0} clicks!", count++); };
    }

    private void initTTS()
    {
        Intent checkIntent = new Intent();
        checkIntent.SetAction(TextToSpeech.Engine.ActionCheckTtsData);
        StartActivityForResult(checkIntent, DATA_CHECK_CODE);
    }

    protected void onActivityResult(int requestCode, int resultCode, Intent data)
    {
        if (requestCode == DATA_CHECK_CODE)
        {
            if (resultCode == TextToSpeech.Engine.DefaultStream)
            {
                mTts = new TextToSpeech(this, (TextToSpeech.IOnInitListener)this);
            }
            else
            {
                Intent installIntent = new Intent();
                installIntent.SetAction(TextToSpeech.Engine.ActionInstallTtsData);
                StartActivity(installIntent);
            }
        }
    }

    public void onInit(int status)
    {
        //if (status == TextToSpeech.SUCCESS)
        //{
            mTts.SetLanguage(Java.Util.Locale.Us);

                mTts.SetPitch(1);
                mTts.Speak("This is a voice test", QueueMode.Flush, null,null);

        //}
    }


}

}

`

Tagged:

Answers

Sign In or Register to comment.