Android Timers Crashing On Cancel

listed in answer

Android Timers Crashing On Cancel
0 votes, 0.00 avg. rating (0% score)

ANSWER:

mailbutton = (Button) findViewById(R.id.emailbutton);

the above line must be in oncreate() because you have a view(R.layout.main) set in oncreate and you function addListenerOnButton() doesn’t know about main layout.

and if still want to it to be in your function then inflate the main.xml and do it.

by Agarwal from http://stackoverflow.com/questions/10220668