Open luccastanan opened 7 years ago
Use startforground () in build notification
Just adding "startForeground(NOTIFICATION_ID, notification);" of method buildNotification() da class RadioPlayerService?
Yp that should work. It shows the notification as long as your media is running
But it does not work, does it need some flag?
Hi, Add " RadioManager.getService().cancelNotification();" in your Activities on onDestroy()
public void onDestroy() {
super.onDestroy();
RadioManager.getService().cancelNotification();
}
Hello ,
Is this able to get working ?
@luccastanan can you help out ?
public class OnClearFromRecentService extends Service {
@Override public IBinder onBind(Intent intent) { return null; }
@Override public int onStartCommand(Intent intent, int flags, int startId) { Log.d("ClearFromRecentService", "Service Started"); return START_NOT_STICKY; }
@Override public void onDestroy() { super.onDestroy(); Log.d("ClearFromRecentService", "Service Destroyed"); }
@Override public void onTaskRemoved(Intent rootIntent) { Log.e("ClearFromRecentService", "END"); //Code here NotificationManager nManager = ((NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE)); nManager.cancel(001); stopSelf(); }
service android:name=".OnClearFromRecentService" android:stopWithTask="false"
3.Then start this service on your radio activity
startService(new Intent(getBaseContext(), OnClearFromRecentService.class));
And now whenever you will clear your app from android recent Then this method onTaskRemoved() will execute.
use this
@Override
protected void onDestroy() {
super.onDestroy();
if (mRadioManager != null) {
mRadioManager.disconnect();
RadioManager.getService().stop();
}
}
use this
@Override protected void onDestroy() { super.onDestroy(); if (mRadioManager != null) { mRadioManager.disconnect(); RadioManager.getService().stop(); } }
in RadioManager.getService().stop();
Supertypes of the following classes cannot be resolved. Please make sure you have the required dependencies in the classpath:
How do I close the notification when the application is closed?