看看这次我是否幸运,有人帮助我。 我有一个mp3音乐服务在线,并在
上出现此错误service.java.lang.NullPointerExceptionat com.sonysabor.example.musicservice.SongPlay1$6.run(SongPlay1.java:304) at java.util.Timer$TimerImpl.run(Timer.java:284)
错误在这一行:
else if(playerStatus == PlayerService.PAUSED)
{
if(Constant.MUSIC_ID.equals(Constant.MUSIC_PLAY_ID_RUNNING))
这是代码片段服务......
progressRefresher.schedule(new TimerTask() {
@Override
public void run() {
if (playerStatus == PlayerService.PLAYING) {
if(Constant.MUSIC_ID.equals(Constant.MUSIC_PLAY_ID_RUNNING))
{
refreshTrack();
// isPlay=true;
}
else if((Constant.MUSIC_ID.equals(Constant.MUSIC_PLAY_ID)))
{
refreshTrackNone();
refreshButtonsNone();
// isPlay=false;
}
}
else if(playerStatus == PlayerService.PAUSED)
{
if(Constant.MUSIC_ID.equals(Constant.MUSIC_PLAY_ID_RUNNING))
{
//isPlay=false;
}
else if((Constant.MUSIC_ID.equals(Constant.MUSIC_PLAY_ID)))
{
refreshTrackNone();
refreshButtonsNone();
// isPlay=false;
}
}
}
}, 0, 500);
/*
这是Logcat:
01-27 20:18:04.444: E/Music Play Id(539): 46
01-27 20:18:04.444: E/Onstart(539): called
01-27 20:18:04.444: W/dalvikvm(539): threadid=32: thread exiting with uncaught exception (group=0x409961f8)
01-27 20:18:04.454: E/poswewew---->(539): 0
01-27 20:18:04.454: E/AndroidRuntime(539): FATAL EXCEPTION: Timer-0
01-27 20:18:04.454: E/AndroidRuntime(539): java.lang.NullPointerException
01-27 20:18:04.454: E/AndroidRuntime(539): at com.sonysabor.example.musicservice.SongPlay1$6.run(SongPlay1.java:302)
01-27 20:18:04.454: E/AndroidRuntime(539): at java.util.Timer$TimerImpl.run(Timer.java:284)
01-27 20:18:04.604: E/array(539): http://nube.myweb.com/mp3/vallenato/Senora_Otto_Serge_Rafael_Ricardo.mp3
01-27 20:18:04.994: D/dalvikvm(539): GC_FOR_ALLOC freed 237K, 26% free 9958K/13447K, paused 362ms
01-27 20:18:05.614: D/dalvikvm(539): GC_FOR_ALLOC freed 31K, 20% free 10808K/13447K, paused 423ms
01-27 20:18:05.844: E/MediaPlayer(539): stop called in state 1
01-27 20:18:05.854: E/MediaPlayer(539): error (-38, 0)
01-27 20:18:05.924: W/MediaPlayer(539): mediaplayer went away with unhandled events
01-27 20:18:07.335: I/Process(539): Sending signal. PID: 539 SIG: 9
01-27 20:18:22.674: E/MediaPlayer(621): start called in state 1
01-27 20:18:22.674: E/MediaPlayer(621): error (-38, 0)
01-27 20:18:22.674: E/MediaPlayer(621): Error (-38,0)
01-27 20:18:22.674: E/MediaPlayer(621): stop called in state 0