I\'m making music player app with simple functionality. But when I listen music on my phone with Android 6, sometimes music stops playing until I turn on display again with powe
Unless you use foreground service, the system will kill your process and mediaplayer will stop. below is a part from from a foreground service ( notification example).
builder.setContentTitle(aMessage) // required
.setSmallIcon(R.mipmap.ic_launcher)
.setContentText(this.getString(R.string.app_name)) // required
.setAutoCancel(false)
.setContentIntent(pendingIntent)
.setVibrate(new long[]{0L})
.setPriority(Notification.PRIORITY_HIGH);
int mId = 1489;
startForeground(mId, builder.build());
The above code is tested and working fine.