Service Crashes With Nullpointerexception At Oncreate
i wanted to check the actual time every 5 mins in a service and mute or unmute the phone depending on the time. earlier i tried to use a while(true) with thread.sleep(300000) at th
Solution 1:
TimermyTimer=newTimer();
MyTimerTask myTimerTask= newMyTimerTask();
AudioManager audioManager;
publicvoidonCreate()
{
super.onCreate();
audioManager = (AudioManager)this.getSystemService(Context.AUDIO_SERVICE);
}
you need to initialize audioManager inside onCreate.
Post a Comment for "Service Crashes With Nullpointerexception At Oncreate"