开发者

TabHost shows default Activity after showing new activity for a while

开发者 https://www.devze.com 2023-04-06 09:03 出处:网络
Thanks for reading. I am facing a problem where when I start a new Activity in my TabHost, the new Activity only shows up for a few seconds before returning to the default Activity in that Tab.

Thanks for reading.

I am facing a problem where when I start a new Activity in my TabHost, the new Activity only shows up for a few seconds before returning to the default Activity in that Tab.

I am using the TabHost for laying out 5 tabs in my app. In one of the tabs, I start a new Activity as follows:


Intent intent = new Intent(this, NewActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
LocalActivityManager manager = MyActivityGroup.ActivityGroup.getLocalActivityManager();
MyActivityGroup.ActivityGroup.replaceView(manager.startActivity("NewActivity", intent).getDecorView() );

In this NewActivitys' onCreate(), I am calling a speech recognition libraries' startRecord() method which is implemented as follows:


private void startRecognition() {
        try {
             recognizer.startRecord(new SpeechRecognizerEvent() {
                 @Override
                 public void onRecognitionComplete(SpeechResult result) {
                           //get result data
                 }
}

All I know is there is a SpeechFrameworkActivity associated with this library in the AndroidManifest.xml.

If I comment out calli开发者_如何学Gong the startRecord() method, the NewActivity does not disappear and continues to show.

I am just clueless about what is going wrong.

From the logs, all I see is this one line:


09-21 21:16:44.860: DEBUG/PhoneWindow(6737): couldn't save which view has focus because the focused view com.android.internal.policy.impl.PhoneWindow$DecorView@4794d9b8 has no id.

I tried using onConfigurationChanged() in my MainTabActivity but that didn't solve the problem.

Please help! Any help/pointers would be great appreciated!


this may happen due to less memory in my case i clear the memory every time before using and it work may be in ur case it works or use system.gc or clear buffer just try this if it helps u .

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号