java - Android:Send the data to another Activity giving Fatal Exception -


i have send details of mainactivity.java activity , print there

i have created onclick event in mainactivity text when click button app crashing inside emulator , getting exception in logcat

mainactivity.java

button buy_button = (button)convertview.findviewbyid(r.id.buy_global);             buy_button.setonclicklistener(new view.onclicklistener() {                  @override                 public void onclick(view v) {                 context context;                         intent intent = new intent("com.coded.sandeep.another");                     intent.putextra("message", "hello mainactivity");                      bundle extras = new bundle();                     extras.putstring("status", "data received!");                      intent.putextras(extras);                      context.startactivity(intent);                  }             });   

another.java

public class extends activity {      @override     protected void oncreate(bundle savedinstancestate) {          super.oncreate(savedinstancestate);         setcontentview(r.layout.another);          // 1. passed intent          intent intent = getintent();          // 2. message value intent         string message = intent.getstringextra("message");          // 3. show message on textview          ((textview)findviewbyid(r.id.tvmessage)).settext(message);            // 5. status value bundle         string status = bundle.getstring("status");          // 6. show status on toast         toast toast = toast.maketext(this, status, toast.length_long);         toast.show();     } } 

logcat

06-03 05:41:52.249: w/dalvikvm(1644): threadid=1: thread exiting uncaught exception (group=0xb4a38ba8)     06-03 05:41:52.379: e/androidruntime(1644): fatal exception: main     06-03 05:41:52.379: e/androidruntime(1644): process: com.coded.sandeep, pid: 1644     06-03 05:41:52.379: e/androidruntime(1644): android.content.activitynotfoundexception: no activity found handle intent { act=com.coded.sandeep.another (has extras) }     06-03 05:41:52.379: e/androidruntime(1644):     @ android.app.instrumentation.checkstartactivityresult(instrumentation.java:1632)     06-03 05:41:52.379: e/androidruntime(1644):     @ android.app.instrumentation.execstartactivity(instrumentation.java:1424)     06-03 05:41:52.379: e/androidruntime(1644):     @ android.app.activity.startactivityforresult(activity.java:3424)     06-03 05:41:52.379: e/androidruntime(1644):     @ android.app.activity.startactivityforresult(activity.java:3385)     06-03 05:41:52.379: e/androidruntime(1644):     @ android.app.activity.startactivity(activity.java:3627)     06-03 05:41:52.379: e/androidruntime(1644):     @ android.app.activity.startactivity(activity.java:3595)     06-03 05:41:52.379: e/androidruntime(1644):     @ com.coded.sandeep.musicdatabaseactivity$imageadapter$3.onclick(musicdatabaseactivity.java:252)     06-03 05:41:52.379: e/androidruntime(1644):     @ android.view.view.performclick(view.java:4438)     06-03 05:41:52.379: e/androidruntime(1644):     @ android.view.view$performclick.run(view.java:18422)     06-03 05:41:52.379: e/androidruntime(1644):     @ android.os.handler.handlecallback(handler.java:733)     06-03 05:41:52.379: e/androidruntime(1644):     @ android.os.handler.dispatchmessage(handler.java:95)     06-03 05:41:52.379: e/androidruntime(1644):     @ android.os.looper.loop(looper.java:136)     06-03 05:41:52.379: e/androidruntime(1644):     @ android.app.activitythread.main(activitythread.java:5017)     06-03 05:41:52.379: e/androidruntime(1644):     @ java.lang.reflect.method.invokenative(native method)     06-03 05:41:52.379: e/androidruntime(1644):     @ java.lang.reflect.method.invoke(method.java:515)     06-03 05:41:52.379: e/androidruntime(1644):     @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:779)     06-03 05:41:52.379: e/androidruntime(1644):     @ com.android.internal.os.zygoteinit.main(zygoteinit.java:595)     06-03 05:41:52.379: e/androidruntime(1644):     @ dalvik.system.nativestart.main(native method) 

is there error in code should change thing

replace this

intent intent = new intent("com.coded.sandeep.another"); 

with

intent intent = new intent(mainactivity.this,another.class); 

mainactivity.this source another.class destination from(mainactivity) , to(another)


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

thorough guide for profiling racket code -