Android :- Second activity not getting started? -


my second activity not starting. below code :-

first activity :-

package infy.route;  import android.app.activity; import android.content.context; import android.content.intent; import android.os.bundle; import android.widget.toast;  public class main extends activity {    /** called when activity first created. */      context mctx;     final static int start =0;     @override    public void oncreate(bundle savedinstancestate) {       super.oncreate(savedinstancestate);       setcontentview(r.layout.welcomescreen);        mctx = this;       thread splashthread = new thread() {          @override          public void run() {             try {                int waited = 0;                while (waited < 2500) {                   sleep(100);                   waited += 100;                }             } catch (interruptedexception e) {                // nothing             } {                finish();                intent = new intent(mctx,infyrouteplanner.class);                mctx.startactivity(i);                ((activity)mctx).startactivityforresult(i, 2);             }          }       };       splashthread.start();    }    @override     protected void onactivityresult(int requestcode, int resultcode, intent data) {         // todo auto-generated method stub         super.onactivityresult(requestcode, resultcode, data);          if(requestcode == start)         {              toast.maketext(mctx, integer.tostring(resultcode), toast.length_short).show();         }     }       @override     public void ondestroy(){         super.ondestroy();         finish();     }  } 

second activity :-

package infy.route;  import android.app.activity; import android.content.context; import android.content.intent; import android.os.bundle; import android.view.view; import android.view.view.onclicklistener; import android.widget.button;  public class infyrouteplanner extends activity {     /** called when activity first created. */      context mctx;   public void oncreate(bundle savedinstancestate) {          super.oncreate(savedinstancestate);          setcontentview(r.layout.main);          mctx = this;          // setting buttons xml         button btn1 = (button)findviewbyid(r.id.btn1);         button btn2 = (button)findviewbyid(r.id.btn2);          // button prepare route address  ( line 30 one)         btn1.setonclicklistener(new onclicklistener(){  //          @override         public void onclick(view v)         {             // start address activity             intent intent = new intent(mctx, fromaddress.class);              /*start activity*/             mctx.startactivity(intent);              /*start activityforresult*/             ((activity)mctx).startactivityforresult(intent, 3);         }         });           // action on clicking button 2         btn2.setonclicklistener(new onclicklistener(){          //  @override         public void onclick(view v)         {             // start activity routeplanning using lat , long values             intent intent = new intent(mctx, routeplanning.class);              /*start activity*/             mctx.startactivity(intent);              /*start activityforresult*/             ((activity)mctx).startactivityforresult(intent, 3);         }     }); }   } 

here stack tracer :-

02-18 20:10:02.253: debug/androidruntime(299): shutting down vm 02-18 20:10:02.263: warn/dalvikvm(299): threadid=3: thread exiting uncaught exception (group=0x4001aa28) 02-18 20:10:02.263: error/androidruntime(299): uncaught handler: thread main exiting due uncaught exception 02-18 20:10:02.283: error/androidruntime(299): java.lang.verifyerror: infy.route.infyrouteplanner$1 02-18 20:10:02.283: error/androidruntime(299):     @ infy.route.infyrouteplanner.oncreate(infyrouteplanner.java:30) 02-18 20:10:02.283: error/androidruntime(299):     @ android.app.instrumentation.callactivityoncreate(instrumentation.java:1123) 02-18 20:10:02.283: error/androidruntime(299):     @ android.app.activitythread.performlaunchactivity(activitythread.java:2364) 02-18 20:10:02.283: error/androidruntime(299):     @ android.app.activitythread.handlelaunchactivity(activitythread.java:2417) 02-18 20:10:02.283: error/androidruntime(299):     @ android.app.activitythread.access$2100(activitythread.java:116) 02-18 20:10:02.283: error/androidruntime(299):     @ android.app.activitythread$h.handlemessage(activitythread.java:1794) 02-18 20:10:02.283: error/androidruntime(299):     @ android.os.handler.dispatchmessage(handler.java:99) 02-18 20:10:02.283: error/androidruntime(299):     @ android.os.looper.loop(looper.java:123) 02-18 20:10:02.283: error/androidruntime(299):     @ android.app.activitythread.main(activitythread.java:4203) 02-18 20:10:02.283: error/androidruntime(299):     @ java.lang.reflect.method.invokenative(native method) 02-18 20:10:02.283: error/androidruntime(299):     @ java.lang.reflect.method.invoke(method.java:521) 02-18 20:10:02.283: error/androidruntime(299):     @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:791) 02-18 20:10:02.283: error/androidruntime(299):     @ com.android.internal.os.zygoteinit.main(zygoteinit.java:549) 02-18 20:10:02.283: error/androidruntime(299):     @ dalvik.system.nativestart.main(native method) 

i don't think related problem, starting activity twice in activity main

mctx.startactivity(i); ((activity)mctx).startactivityforresult(i, 2); 

the first time without expecting result, second 1 expecting it. normally, start activity once. , same 'issue' have twice in activity infyrouteplanner now, problem, have checked this thread? hope helps


Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -