Child Activity in Android

Posted by Martin Marinov on Stack Overflow See other posts from Stack Overflow or by Martin Marinov
Published on 2010-06-17T16:03:19Z Indexed on 2010/06/17 20:03 UTC
Read the original article Hit count: 241

So I have two Activities. The main is called Main, and the child one is called Child. When a button is clicked in the main activity it triggers the following piece of code:

Intent i = new Intent(Main.this, Child.class);
Main.this.startActivity(i);

That opens the Child activity.

As soon as I call finish() or press the back button within the child activity instead of going back to the main one, the app just closes. Can you give me a hint where the problem might be :(

P.S. By trial and error I found out that if edit AndroidManifest.xml and add

android:theme="@android:style/Theme.Dialog"

within the declaration of Child the back button and calling finish() behaves as expected: closes the child activity and brings the main into focus. The problem is that when I start typing in an EditText the screen starts flickering (rather bizzare). So I can't use it as a dialog. My main activity uses the camera, so that might be making problems. Although when the child activity is started, the onPause event is fired and it stops the camera until onResume is called.

© Stack Overflow or respective owner

Related posts about java

Related posts about android