i have written code in splashscreenactivity
in oncreate()
:
timer t = new timer(); boolean checkconnection=new mainactivity().checkconnection(this); if (checkconnection) { t.schedule(new splashscreenactivity(), 3000); } else { toast.maketext(splashscreenactivity.this, "connection not found...plz check connection", 3000).show(); }
this error i'm getting:
the method schedule(timertask, date) in type timer not applicable arguments (splashscreenactivity, int)
first of all, should never instantiate activity
new
keyword.
you example make checkconnection()
method of splashscreenactivity
.
the cause of error schedule()
method expects timertask
first parameter, you're passing activity
it.
something should work:
if (checkconnection) { t.schedule(new timertask() { @override public void run() { intent intent = new intent(splashscreenactivity.this, mainactivity.class); startactivity(intent); } }, 3000); } else { toast.maketext(splashscreenactivity.this, "connection not found...plz check connection", toast.length_long).show(); }
Comments
Post a Comment