Note that there are some explanatory texts on larger screens.

plurals
  1. POWhen clicked on a Button, the application is force closed
    primarykey
    data
    text
    <p>I am facing an issue with a button onclick. I checked with previously asked questions, but was not able to figure out the problem, where exactly it lies. The first time, when I click on, 'Next' button, it successfully moves to next page, but in the second page, after entering details, when the 'Proceed'button is clicked, the application crashes.</p> <p>Activity1:</p> <pre><code>package com.application.P1; //import com.application.P1.R; //import android.R; import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.TextView; public class P1Activity extends Activity implements View.OnClickListener{ /** Called when the activity is first created. */ // @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); //Using TextView to Give a Home Page Screen TextView tv=new TextView(this); tv.setText("WELCOME TO Application Click on Next to Proceed"); setContentView(R.layout.main); } public void Welcome( View v){ // Toast.makeText(this, "Please enter your Nickname and proceed further", Toast.LENGTH_SHORT).show(); Intent myActivity = new Intent(this,Activity2.class); startActivity(myActivity); // EditText t } @Override public void onClick(View v) { // TODO Auto-generated method stub } } </code></pre> <p>Activity2:</p> <pre><code>package com.application.P1; import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.TextView; public class Activity2 extends Activity implements View.OnClickListener{ /** Called when the activity is first created. */ // @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.login); } public void Proceed4( View v){ // Toast.makeText(this, "Thanks for entering your nickname", Toast.LENGTH_SHORT).show(); Intent myActivity2 = new Intent(this,Activity3.class); startActivity(myActivity2); // EditText t } @Override public void onClick(View v) { // TODO Auto-generated method stub } } </code></pre> <p>Activity3:</p> <pre><code>package com.application.P1; import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.view.View; import android.widget.TextView; //import android.content.Intent; //import android.widget.Button; import android.widget.Toast; public class Activity3 extends Activity implements View.OnClickListener{ /** Called when the activity is first created. */ // @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.check); } @Override public void onClick(View v) { // TODO Auto-generated method stub } } </code></pre> <p>All the three activities are in same package. In the second activity, after button click, when a message is toasted, the toasted message is coming properly. But, when the next activity is called, it is not coming.</p> <pre><code>XML Coding: </code></pre> <p>Main.xml:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" android:background="@drawable/backrepeat" &gt; &lt;TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/hello" /&gt; &lt;Button android:text="@string/Next" android:id="@+id/Button01" android:layout_width="fill_parent" android:layout_height="wrap_content" android:onClick="Welcome"/&gt; &lt;/LinearLayout&gt; </code></pre> <p>login.xml:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" &gt; &lt;TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/mynickname" /&gt; &lt;EditText android:id="@+id/mynickname3" android:singleLine="true" android:layout_width="fill_parent" android:layout_height="wrap_content" /&gt; &lt;Button android:text="@string/Proceed" android:id="@+id/Button02" android:layout_width="fill_parent" android:layout_height="wrap_content" android:onClick="Proceed4"/&gt; &lt;/LinearLayout&gt; </code></pre> <p>Check.xml:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" &gt; &lt;TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/hello3" /&gt; &lt;/LinearLayout&gt; </code></pre> <p>AndroidManifest.xml:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.application.P1" android:versionCode="1" android:versionName="1.0" &gt; &lt;uses-sdk android:minSdkVersion="10" /&gt; &lt;application android:icon="@drawable/cherry" android:label="@string/app_name" &gt; &lt;activity android:name=".P1Activity" 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=".Activity2"&gt; &lt;/activity&gt; &lt;activity android:name=".Activity3"&gt;&lt;/activity&gt; &lt;/application&gt; &lt;/manifest&gt; </code></pre> <p>03-22 00:50:27.125: E/AndroidRuntime(857): at java.lang.reflect.Method.invokeNative(Native Method) 03-22 00:50:27.125: E/AndroidRuntime(857): at java.lang.reflect.Method.invoke(Method.java:507) 03-22 00:50:27.125: E/AndroidRuntime(857): at android.view.View$1.onClick(View.java:2139) 03-22 00:50:27.125: E/AndroidRuntime(857): ... 11 more 03-22 00:50:27.125: E/AndroidRuntime(857): Caused by: android.content.ActivityNotFoundException: Unable to find explicit activity </p> <pre><code>class {com.application.P1/com.application.P1.Activity3}; have you declared this activity in your AndroidManifest.xml? 03-22 00:50:27.125: E/AndroidRuntime(857): at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1405) 03-22 00:50:27.125: E/AndroidRuntime(857): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1379) 03-22 00:50:27.125: E/AndroidRuntime(857): at android.app.Activity.startActivityForResult(Activity.java:2827) 03-22 00:50:27.125: E/AndroidRuntime(857): at android.app.Activity.startActivity(Activity.java:2933) 03-22 00:50:27.125: E/AndroidRuntime(857): at com.application.P1.Activity2.Proceed4(Activity2.java:31) 03-22 00:50:27.125: E/AndroidRuntime(857): ... 14 more 03-22 00:50:29.867: I/Process(857): Sending signal. PID: 857 SIG: 9 </code></pre> <p>Values.xml:</p> <p> </p> <pre><code>&lt;string name="hello"&gt;Welcome to Expresso Application&lt;/string&gt; &lt;string name="Next"&gt;Next&lt;/string&gt; &lt;string name="app_name"&gt;Expresso2&lt;/string&gt; &lt;string name="Proceed"&gt;Proceed&lt;/string&gt; &lt;string name="Nickname"&gt;Nickname&lt;/string&gt; &lt;string name="mynickname"&gt;myNickname&lt;/string&gt; &lt;string name="hello3"&gt;Tensions&lt;/string&gt; </code></pre> <p></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.
    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