Note that there are some explanatory texts on larger screens.

plurals
  1. PONot Able to Launch Activity using intent
    text
    copied!<p>I have a button initialized</p> <pre><code>button1= (Button)findViewById(R.id.button1); </code></pre> <p>Tn the OnClick() function I have</p> <pre><code>public void onClick(View arg0) { // TODO Auto-generated method stub Intent intent = new Intent(this, MainActivity2.class); startActivity(intent); } </code></pre> <p>My New Activity's name is MainActivity2 in the Manifest file </p> <pre><code> &lt;activity android:name="com.example.intent.MainActivity2" android:label="@string/title_activity_main_activity2" &gt; &lt;/activity&gt; </code></pre> <p>But the 2nd activity never launches</p> <p>Please help.</p> <p><strong>Activity 1</strong></p> <pre><code>public class MainActivity extends Activity implements OnClickListener { Button button1; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); button1= (Button)findViewById(R.id.button1); } public void onClick(View arg0) { // TODO Auto-generated method stub Intent intent = new Intent(this, MainActivity2.class); startActivity(intent); } } </code></pre> <p><strong>XML LAYOUT</strong></p> <pre><code>&lt;activity android:name="com.example.intent.MainActivity" android:label="@string/app_name" &gt; &lt;intent-filter&gt; &lt;action android:name="android.intent.action.MAIN" /&gt; &lt;category android:name="android.intent.category.LAUNCHER" /&gt; &lt;/intent-filter&gt; &lt;/activity&gt; &lt;activity android:name="com.example.intent.MainActivity2" android:label="@string/title_activity_main_activity2" &gt; &lt;/activity&gt; &lt;/application&gt; </code></pre>
 

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