variables - android data passing to another class by a button click -
im trying pass data testsearch class googlesearch class. assigned values of tedit test string variable , want pass googlesearch class. app crash when run it.
button disp=(button)findviewbyid(r.id.btn_search); disp.setonclicklistener(new view.onclicklistener() { @override public void onclick(view arg0) { edittext inputtxt = (edittext) findviewbyid(r.id.edittext1); string str = inputtxt.gettext().tostring().tolowercase().trim(); arraylist<hashmap<string, string>> userlist = controller.searchbook(str); if (userlist.size() != 0) { //do } else { intent intent = new intent("com.example.captchalib.googlesearch"); intent.putextra("message", str); startactivity(intent); } } });
in googlesearch class used below code catch intent
protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.search_menu); intent intent = getintent(); string message = intent.getstringextra("message"); ((textview)findviewbyid(r.id.receive)).settext(message); }
why happening , how solve ?
logcat
android.content.activitynotfoundexception: no activity found handle intent { act=com.example.captchalib.googlesearch (has extras) } android.app.instrumentation.checkstartactivityresult(instrumentation.java:1545) android.app.instrumentation.execstartactivity(instrumentation.java:1416)
change line:
intent intent = new intent("com.example.captchalib.googlesearch");
to:
intent intent = new intent(testsearch.this, googlesearch.class);
Comments
Post a Comment