在Android扩展中为GAMEMAKER STUDIO找不到扩展类的argfree方法

时间:2017-05-01 21:48:47

标签: java android game-maker-language

我正在为gamemaker工作室制作一个文本到语音的android扩展,我收到了这个错误: 05-01 17:16:41.304 16939 17013我yoyo:在扩展类上找不到argfree方法:getMic [] 当试图在游戏中使用我的扩展时。游戏没有崩溃,它只能在扩展中找不到任何东西。那究竟什么是argfree方法呢?

我也尝试过将onCreate方法更改为公共方法并从GM:S和其他几个方面调用它但没有运气。以下是相关代码,如果您需要更多信息,请询问。

java class TtsStt:

       protected void onCreate(Bundle savedInstanceState) { //HERE is where I tried replacing
//protected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState); 
//with just public void initTTS() {...} but got same error   
    super.onCreate(savedInstanceState);
    setContentView(R.layout.tts_stt);
    preferences = getSharedPreferences(PREFS,0);
    editor = preferences.edit();
    editor.putString(TSTYLE, "military time").apply();
    RunnerActivity.CurrentActivity.findViewById(R.id.microphoneButton).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            listen();
        }
    });
    loadQuestions();
    tts = new TextToSpeech(RunnerActivity.CurrentActivity, new TextToSpeech.OnInitListener() { 
    @Override
        public void onInit(int status) {
            if (status == TextToSpeech.SUCCESS) {
                int result = tts.setLanguage(Locale.US);
                if (result == TextToSpeech.LANG_MISSING_DATA || result == TextToSpeech.LANG_NOT_SUPPORTED) {
                    Log.i("yoyo", "This Language is not supported");
                }
                speak("Hello");
            } else {
                Log.i("yoyo", "Initilization Failed!");
            }
        }
    });
}
public void getMic() {
            listen(); 
} 


private void listen(){
    Intent i = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
    i.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
    i.putExtra(RecognizerIntent.EXTRA_LANGUAGE, Locale.getDefault());
    i.putExtra(RecognizerIntent.EXTRA_PROMPT, "Say something");
    try {
        RunnerActivity.CurrentActivity.startActivityForResult(i, 100);
    } catch (ActivityNotFoundException a) {
      Log.i("yoyo", "Your device doesn't support Speech Recognition");
    }
}

在活动级别在我的清单中我注入了这个:

<activity android:name="${YYAndroidPackageName}.TtsStt" 
android:theme="@style/Theme.AppCompat.NoActionBar"
android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
            <category android:name="android.intent.category.LAUNCHER" />
        />
    />

并在清单中注入了gradle依赖项:

compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.2.1'

1 个答案:

答案 0 :(得分:0)

答案是非常意外的,当在gamemaker工作室和android java之间使用扩展代码时,如果你需要使用onCreate方法,你必须不写保护的void onCreate(.......) 相反,你必须使用public void onCreate(......) 这与java中的正常和预期相反,我只是通过阅读一篇关于为什么onCreate总是受到保护的帖子并且看到某人没有理由不做其他人的回复来解决这个问题,所以我做了其他的工作!