File tree Expand file tree Collapse file tree 1 file changed +16
-0
lines changed
app/src/main/java/com/sidzi/circleofmusic/services Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change 7
7
import android .media .AudioManager ;
8
8
import android .media .MediaPlayer ;
9
9
import android .os .Binder ;
10
+ import android .os .Handler ;
10
11
import android .os .IBinder ;
11
12
import android .support .annotation .Nullable ;
12
13
import android .support .v4 .content .LocalBroadcastManager ;
@@ -58,6 +59,21 @@ public void onCreate() {
58
59
} catch (SQLException e ) {
59
60
e .printStackTrace ();
60
61
}
62
+ final Handler mHandler = new Handler ();
63
+ final Runnable mRunnable = new Runnable () {
64
+ @ Override
65
+ public void run () {
66
+ try {
67
+ if (!mMediaPlayer .isPlaying ())
68
+ onDestroy ();
69
+ } catch (NullPointerException e ) {
70
+ onDestroy ();
71
+ } finally {
72
+ mHandler .postDelayed (this , 15000 );
73
+ }
74
+ }
75
+ };
76
+ mHandler .postDelayed (mRunnable , 15000 );
61
77
}
62
78
63
79
@ Override
You can’t perform that action at this time.
0 commit comments