常にフルスクリーンでタイトルバーなしで実行するアプリケーションを実装しています。ユーザーがボタンをクリックして、音声認識機能の API を使用する状況があります。Android ネイティブ ウィンドウが呼び出され、ユーザーの声が分析されます。しかし、その後、タイトル バーが再び表示されます。問題は、それを非表示にするメソッドが onCreate メソッドで機能するため、再度非表示にできないことです。
これは音声 API を呼び出すメソッドで、タイトル バーが再び表示されます。
public void VoiceCaptureButtonClick(View v) {
//- The title bar is properly hidden at this point.
//Code for calling the voice recognition API:
Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
intent.putExtra(RecognizerIntent.EXTRA_PROMPT, "Voice recognition Demo...");
startActivityForResult(intent, REQUEST_CODE);
//- Now the title bar is visible again, and I don't manage to hide it anymore.
// if I use the method requestWindowFeature(Window.FEATURE_NO_TITLE);
// I run into a exception : "requestFeature() must be called before adding content"
}
編集:
上記のメソッドを呼び出すまでは、タイトル バーを非表示にし、アプリケーションを全画面表示にするために使用しているコードを次に示します。これは完全に機能します。
<application
...
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
...
</application>
私はアンドロイド 2.3.3 と Eclipse を使用しています。