Dismiss notifications when notifications fragment is opened

This commit is contained in:
Eugen Rochko 2017-03-09 17:03:13 +01:00
parent d09e9706b6
commit 636c2f266e
2 changed files with 10 additions and 1 deletions

View File

@ -15,6 +15,7 @@
package com.keylesspalace.tusky; package com.keylesspalace.tusky;
import android.app.NotificationManager;
import android.content.Context; import android.content.Context;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.os.Bundle; import android.os.Bundle;
@ -70,6 +71,14 @@ public class NotificationsFragment extends SFragment implements
super.onDestroy(); super.onDestroy();
} }
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
NotificationManager notificationManager =
(NotificationManager) getActivity().getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.cancel(PullNotificationService.NOTIFY_ID);
super.onCreate(savedInstanceState);
}
@Nullable @Nullable
@Override @Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,

View File

@ -57,7 +57,7 @@ import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory; import retrofit2.converter.gson.GsonConverterFactory;
public class PullNotificationService extends IntentService { public class PullNotificationService extends IntentService {
private static final int NOTIFY_ID = 6; // This is an arbitrary number. static final int NOTIFY_ID = 6; // This is an arbitrary number.
private static final String TAG = "PullNotifications"; // logging tag and Volley request tag private static final String TAG = "PullNotifications"; // logging tag and Volley request tag
public PullNotificationService() { public PullNotificationService() {