Note that there are some explanatory texts on larger screens.

plurals
  1. POChild Activity in Android
    primarykey
    data
    text
    <p>So I have two Activities. The main is called <strong>Main</strong>, and the child one is called <strong>Child</strong>. When a button is clicked in the main activity it triggers the following piece of code:</p> <pre><code>Intent i = new Intent(Main.this, Child.class); Main.this.startActivity(i); </code></pre> <p>That opens the <strong>Child</strong> activity.</p> <p>As soon as I call <strong>finish()</strong> 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> <p><em>P.S.</em> By trial and error I found out that if edit <em>AndroidManifest.xml</em> and add </p> <pre><code>android:theme="@android:style/Theme.Dialog" </code></pre> <p>within the declaration of <strong>Child</strong> the back button and calling <strong>finish()</strong> behaves as expected: closes the child activity and brings the main into focus. The problem is that when I start typing in an <strong>EditText</strong> 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 <strong>onPause</strong> event is fired and it stops the camera until <strong>onResume</strong> is called.</p> <p>Edit:</p> <p>So I tried using <strong>startActivityForResult</strong> and added</p> <pre><code>Toast.makeText(this, "onPause", Toast.LENGTH_SHORT).show(); </code></pre> <p>to the <strong>onPause</strong> and a similar one to the <strong>onResume</strong> methods. When the Child returns <strong>onResume</strong> doesn't get triggered. I even overrided <strong>onActivityResult</strong> and even that doesn't get triggered. :( So bizarre...</p> <p><strong>I think I found the problem but I can't solve it myself</strong></p> <p>When the <strong>Child</strong> activity is activated, <strong>onStop</strong> and immediately after that <strong>onDestroy</strong> are invoked within the <strong>Main</strong> activity. But why?!?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload