android - unfortunately <app name > has stopped onclick to -
i doing simple application: when click on button
take me next activity
. problem when run emulator , click on button
pops message
unfrotunately < app name> has stopped
here code:
main activity:
package learn2develop.uingintent; import android.app.activity; import android.content.intent; import android.os.bundle; import android.view.menu; import android.view.view; public class mainactivity extends activity { @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); } public void onclick(view view){ startactivity(new intent("learn2develop.uingintent.secondd")); } @override public boolean oncreateoptionsmenu(menu menu) { // inflate menu; adds items action bar if present. getmenuinflater().inflate(r.menu.main, menu); return true; } }
second activity called : secondd
package learn2develop.uingintent; import android.os.bundle; import android.app.activity; import android.view.menu; public class secondd extends activity { @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_secondd); } @override public boolean oncreateoptionsmenu(menu menu) { // inflate menu; adds items action bar if present. getmenuinflater().inflate(r.menu.secondd, menu); return true; } }
and xml file of main activity
<relativelayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingbottom="@dimen/activity_vertical_margin" android:paddingleft="@dimen/activity_horizontal_margin" android:paddingright="@dimen/activity_horizontal_margin" android:paddingtop="@dimen/activity_vertical_margin" tools:context=".mainactivity" > <textview android:id="@+id/textview1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/hello_world" /> <button android:id="@+id/button1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@+id/textview1" android:layout_margintop="50dp" android:layout_torightof="@+id/textview1" android:text="go" android:onclick="onclick" /> </relativelayout>
here log cat:
03-10 03:10:54.574: i/dalvikvm(564): threadid=3: reacting signal 3 03-10 03:10:55.066: i/dalvikvm(564): wrote stack traces '/data/anr/traces.txt' 03-10 03:10:55.256: i/dalvikvm(564): threadid=3: reacting signal 3 03-10 03:10:55.315: i/dalvikvm(564): wrote stack traces '/data/anr/traces.txt' 03-10 03:10:55.735: i/dalvikvm(564): threadid=3: reacting signal 3 03-10 03:10:55.834: i/dalvikvm(564): wrote stack traces '/data/anr/traces.txt' 03-10 03:10:56.114: d/libegl(564): loaded /system/lib/egl/libgles_android.so 03-10 03:10:56.187: d/libegl(564): loaded /system/lib/egl/libegl_emulation.so 03-10 03:10:56.206: d/(564): hostconnection::get() new host connection established 0x18c178, tid 564 03-10 03:10:56.246: d/libegl(564): loaded /system/lib/egl/libglesv1_cm_emulation.so 03-10 03:10:56.287: d/libegl(564): loaded /system/lib/egl/libglesv2_emulation.so 03-10 03:10:56.325: i/dalvikvm(564): threadid=3: reacting signal 3 03-10 03:10:56.434: i/dalvikvm(564): wrote stack traces '/data/anr/traces.txt' 03-10 03:10:56.585: w/egl_emulation(564): eglsurfaceattrib not implemented 03-10 03:10:56.684: d/openglrenderer(564): enabling debug mode 0 03-10 03:10:56.764: i/dalvikvm(564): threadid=3: reacting signal 3 03-10 03:10:56.834: i/dalvikvm(564): wrote stack traces '/data/anr/traces.txt' 03-10 03:10:57.274: i/dalvikvm(564): threadid=3: reacting signal 3 03-10 03:10:57.314: i/dalvikvm(564): wrote stack traces '/data/anr/traces.txt' 03-10 03:10:57.814: i/dalvikvm(564): threadid=3: reacting signal 3 03-10 03:10:57.866: i/dalvikvm(564): wrote stack traces '/data/anr/traces.txt' 03-10 03:11:18.103: d/androidruntime(564): shutting down vm 03-10 03:11:18.103: w/dalvikvm(564): threadid=1: thread exiting uncaught exception (group=0x409c01f8) 03-10 03:11:18.176: e/androidruntime(564): fatal exception: main 03-10 03:11:18.176: e/androidruntime(564): java.lang.illegalstateexception: not execute method of activity 03-10 03:11:18.176: e/androidruntime(564): @ android.view.view$1.onclick(view.java:3044) 03-10 03:11:18.176: e/androidruntime(564): @ android.view.view.performclick(view.java:3511) 03-10 03:11:18.176: e/androidruntime(564): @ android.view.view$performclick.run(view.java:14105) 03-10 03:11:18.176: e/androidruntime(564): @ android.os.handler.handlecallback(handler.java:605) 03-10 03:11:18.176: e/androidruntime(564): @ android.os.handler.dispatchmessage(handler.java:92) 03-10 03:11:18.176: e/androidruntime(564): @ android.os.looper.loop(looper.java:137) 03-10 03:11:18.176: e/androidruntime(564): @ android.app.activitythread.main(activitythread.java:4424) 03-10 03:11:18.176: e/androidruntime(564): @ java.lang.reflect.method.invokenative(native method) 03-10 03:11:18.176: e/androidruntime(564): @ java.lang.reflect.method.invoke(method.java:511) 03-10 03:11:18.176: e/androidruntime(564): @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:784) 03-10 03:11:18.176: e/androidruntime(564): @ com.android.internal.os.zygoteinit.main(zygoteinit.java:551) 03-10 03:11:18.176: e/androidruntime(564): @ dalvik.system.nativestart.main(native method) 03-10 03:11:18.176: e/androidruntime(564): caused by: java.lang.reflect.invocationtargetexception 03-10 03:11:18.176: e/androidruntime(564): @ java.lang.reflect.method.invokenative(native method) 03-10 03:11:18.176: e/androidruntime(564): @ java.lang.reflect.method.invoke(method.java:511) 03-10 03:11:18.176: e/androidruntime(564): @ android.view.view$1.onclick(view.java:3039) 03-10 03:11:18.176: e/androidruntime(564): ... 11 more 03-10 03:11:18.176: e/androidruntime(564): caused by: android.content.activitynotfoundexception: no activity found handle intent { act=com.example.salah.secondactivity } 03-10 03:11:18.176: e/androidruntime(564): @ android.app.instrumentation.checkstartactivityresult(instrumentation.java:1512) 03-10 03:11:18.176: e/androidruntime(564): @ android.app.instrumentation.execstartactivity(instrumentation.java:1384) 03-10 03:11:18.176: e/androidruntime(564): @ android.app.activity.startactivityforresult(activity.java:3190) 03-10 03:11:18.176: e/androidruntime(564): @ android.app.activity.startactivity(activity.java:3297) 03-10 03:11:18.176: e/androidruntime(564): @ com.example.salah.mainactivity.onclick(mainactivity.java:17) 03-10 03:11:18.176: e/androidruntime(564): ... 14 more 03-10 03:11:19.154: i/dalvikvm(564): threadid=3: reacting signal 3 03-10 03:11:19.193: i/dalvikvm(564): wrote stack traces '/data/anr/traces.txt' 03-10 03:11:24.534: i/process(564): sending signal. pid: 564 sig: 9
problem is(was) @ androidmanifest.xml file, simple adding new activity fix problem.
<activity android:name=".secondd"></activity>
Comments
Post a Comment