Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You have a <code>NullPointerException</code> because <code>SimpleActivity.onCreate()</code> is called directly by <code>ComposedActivity</code> while it is supposed to be called thru the use of an <code>Intent</code>. So when <code>Activity</code>, superclass of <code>SimpleActivity</code>, tries to retrieve the <code>Intent</code> that was used to activate it, it finds <code>null</code> and crashes as this is unexpected.</p> <p>On top of this <code>ComposedActivity</code> extends <code>Activity</code> but you didn't call <code>super.onCreate()</code> from <code>ComposedActivity.onCreate()</code>. This normally leads the following exception to be thrown: </p> <pre><code>android.app.SuperNotCalledException: Activity did not call through to super.onCreate() </code></pre> <p>But reading your question, this is probably by mistake that <code>ComposedActivity</code> extends <code>Activity</code>. The way I understood the question, <code>ComposedActivity</code> should not inherit from <code>Activity</code> but delegate all the <code>Activity</code> stuff to <code>SimpleActivity</code>.</p> <p>Anyway, and despite the source of wisdom that Effective Java is, <a href="http://developer.android.com/resources/tutorials/hello-world.html#ui" rel="nofollow">another source of wisdom</a> promotes the inheritance from <code>Activity</code> as a best practice. More seriously, even if the code we find in tutorials in sometimes questionable, I think inheriting from <code>Activity</code> is from far the best way to implement an <code>Activity</code>: this was designed that way by Android. </p>
 

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