I get this error. not on any device, just on some. This is all the report:
java.lang.NullPointerException
at eu.innovaapps.tpark.ro.MainSms$4$1$1.run(MainSms.java:444)
at java.util.Timer$TimerImpl.run(Timer.java:284)
and it comes from:
buton.setEnabled(false);
Timer buttonTimer = new Timer();
buttonTimer.schedule(new TimerTask() {
@Override
public void run() {
getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
buton.setEnabled(true);
}
});
}
}, 5000);
When i press the button it gets disabled and after 5 seconds it gets enabled again.
Line 444 is getActivity().runOnUiThread(new Runnable() {
.
I'd appreciate alot if you could help me solve this error.
EDIT: I got the same problem as here: Scheduled Task in Fragment returns getActivity as null
If the button in disabled, and i press the back button of the phone, i get this error which sends me at this part of the code. Is there a way i could stop the timer if the back button is pressed?