本文整理汇总了Java中android.app.NotificationManager.cancelAll方法的典型用法代码示例。如果您正苦于以下问题:Java NotificationManager.cancelAll方法的具体用法?Java NotificationManager.cancelAll怎么用?Java NotificationManager.cancelAll使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.app.NotificationManager
的用法示例。
在下文中一共展示了NotificationManager.cancelAll方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: cancelActiveNotifications
import android.app.NotificationManager; //导入方法依赖的package包/类
private static void cancelActiveNotifications(@NonNull Context context) {
NotificationManager notifications = ServiceUtil.getNotificationManager(context);
notifications.cancel(SUMMARY_NOTIFICATION_ID);
if (Build.VERSION.SDK_INT >= 23) {
try {
StatusBarNotification[] activeNotifications = notifications.getActiveNotifications();
for (StatusBarNotification activeNotification : activeNotifications) {
if (activeNotification.getId() != CallNotificationBuilder.WEBRTC_NOTIFICATION) {
notifications.cancel(activeNotification.getId());
}
}
} catch (Throwable e) {
// XXX Appears to be a ROM bug, see #6043
Log.w(TAG, e);
notifications.cancelAll();
}
}
}
示例2: onTaskRemoved
import android.app.NotificationManager; //导入方法依赖的package包/类
@Override
public void onTaskRemoved(Intent rootIntent) {
AppPreference.setSelectionVerse(null);
// //delete all selection in the image
// Intent resetImage = new Intent(AppConstants.Highlight.RESET_IMAGE);
// resetImage.putExtra(AppConstants.Highlight.RESET , true);
// LocalBroadcastManager.getInstance(getApplicationContext()).sendBroadcast(resetImage);
//// Toast.makeText(this, "Service Destroyeddddddd", Toast.LENGTH_LONG).show();
// QuranPageFragment.SELECTION = false;
// HighlightImageView.selectionFromTouch = false;
//// super.onTaskRemoved(rootIntent);
NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.cancelAll();
// Intent intent = new Intent(getApplicationContext(), HomeActivity.class);
// intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
// intent.putExtra("EXIT", true);
// startActivity(intent);
// quit();
trimCache();
deleteCache(getApplicationContext());
}
示例3: cancelNotify
import android.app.NotificationManager; //导入方法依赖的package包/类
/**
* 去掉通知图标
*
* @param id
* @param type
*/
public static void cancelNotify(String id, String type, Context con) {
NotificationManager manger = (NotificationManager) con.getSystemService(
Context.NOTIFICATION_SERVICE);
if (TextUtils.isEmpty(id) || TextUtils.isEmpty(type)) {
manger.cancelAll();
} else {
int notifyid = 1;
try {
notifyid = Integer.parseInt(id) + Integer.parseInt(type);
} catch (NumberFormatException e) {
e.printStackTrace();
}
manger.cancel(notifyid);
}
}
示例4: NovaNotificationManager
import android.app.NotificationManager; //导入方法依赖的package包/类
public NovaNotificationManager(MusicService service) throws RemoteException {
mService = service;
updateSessionToken();
mNotificationManager = (NotificationManager) mService.getSystemService(Context.NOTIFICATION_SERVICE);
createNotificationChannelForAndroidO();
String pkgName = mService.getPackageName();
mPlayIntent = PendingIntent.getBroadcast(mService, REQUEST_CODE,
new Intent(ACTION_PLAY).setPackage(pkgName), PendingIntent.FLAG_CANCEL_CURRENT);
mPauseIntent = PendingIntent.getBroadcast(mService, REQUEST_CODE,
new Intent(ACTION_PAUSE).setPackage(pkgName), PendingIntent.FLAG_CANCEL_CURRENT);
mPrevIntent = PendingIntent.getBroadcast(mService, REQUEST_CODE,
new Intent(ACTION_PREV).setPackage(pkgName), PendingIntent.FLAG_CANCEL_CURRENT);
mNextIntent = PendingIntent.getBroadcast(mService, REQUEST_CODE,
new Intent(ACTION_NEXT).setPackage(pkgName), PendingIntent.FLAG_CANCEL_CURRENT);
if (mNotificationManager != null) {
mNotificationManager.cancelAll();
}
}
示例5: onResume
import android.app.NotificationManager; //导入方法依赖的package包/类
@Override
protected void onResume() {
super.onResume();
// Make sure we have the latest content
updateAdapter();
// Drop all user notifications
NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
notificationManager.cancelAll();
// Register broadcast receiver for notifications
IntentFilter updateFilter = new IntentFilter(UpdateService.BROADCAST_UPDATE_FINISHED);
updateFilter.setPriority(UpdateService.BROADCAST_PRIORITY_UI);
registerReceiver(updateReceiver, updateFilter);
IntentFilter skippedFilter = new IntentFilter(UpdateService.BROADCAST_UPDATE_SKIPPED);
registerReceiver(updateReceiver, skippedFilter);
// Trigger update if desired
refreshLayout.setRefreshing(false);
if(shouldPerformUpdate) {
requestUpdate();
shouldPerformUpdate = false;
}
}
示例6: onResume
import android.app.NotificationManager; //导入方法依赖的package包/类
@Override
protected void onResume() {
super.onResume();
//进入界面清除通知
NotificationManager notificationManager = (NotificationManager) getApplicationContext().getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.cancelAll();
if (!isHaveMsg(currentUserList,"2"))
currentUserList.add(new User("微信机器人(未开放)", "2", WEIXIN, "用于控制服务端。", getCurTime(), "1", 2, "0"));
if (!isHaveMsg(currentUserList,"1"))
currentUserList.add(new User("QQ机器人(未开放)", "1", QQ, "用于控制服务端。", getCurTime(), "1", 1, "0"));
if (!isHaveMsg(currentUserList,"0"))
currentUserList.add(new User("欢迎使用!", "0", SYS, "请点击右上角选项获取设备码。", getCurTime(), "1", 0, "0"));
}
示例7: deliverStoredMessages
import android.app.NotificationManager; //导入方法依赖的package包/类
public void deliverStoredMessages()
{
final SharedPreferences prefs = getGcmPreferences(mContext);
int messageCount = prefs.getInt(PROPERTY_MESSAGE_COUNT, 0);
Log.i("yoyo", "GCM: sending " + messageCount + " stored messages");
if( messageCount > 0 )
{
for( int i = 1; i <= messageCount; ++i)
{
String keyData = PROPERTY_MESSAGE_N + Integer.toString(i);
String keyType = PROPERTY_MESSAGE_TYPE_N + Integer.toString(i);
String data = prefs.getString(keyData, "");
int msgType = prefs.getInt(keyType, PUSH_EVENT_REMOTE);
RunnerJNILib.GCMPushResult( data, msgType, true );
}
}
//remove the messages
SharedPreferences.Editor editor = prefs.edit();
editor.putInt(PROPERTY_MESSAGE_COUNT, 0);
for( int i = 0; i < messageCount; ++i)
{
String key = PROPERTY_MESSAGE_N + Integer.toString(i);
editor.remove(key);
}
editor.commit();
//we can remove notifications now, since we have delivered all the data to the app
NotificationManager notificationManager = (NotificationManager)mContext.getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.cancelAll();
}
示例8: MediaNotificationManager
import android.app.NotificationManager; //导入方法依赖的package包/类
public MediaNotificationManager(MusicService service) {
mService = service;
mNotificationManager =
(NotificationManager) mService.getSystemService(Context.NOTIFICATION_SERVICE);
mPlayAction =
new NotificationCompat.Action(
R.drawable.ic_play_arrow_white_24dp,
mService.getString(R.string.label_play),
MediaButtonReceiver.buildMediaButtonPendingIntent(
mService,
PlaybackStateCompat.ACTION_PLAY));
mPauseAction =
new NotificationCompat.Action(
R.drawable.ic_pause_white_24dp,
mService.getString(R.string.label_pause),
MediaButtonReceiver.buildMediaButtonPendingIntent(
mService,
PlaybackStateCompat.ACTION_PAUSE));
mNextAction =
new NotificationCompat.Action(
R.drawable.ic_skip_next_white_24dp,
mService.getString(R.string.label_next),
MediaButtonReceiver.buildMediaButtonPendingIntent(
mService,
PlaybackStateCompat.ACTION_SKIP_TO_NEXT));
mPrevAction =
new NotificationCompat.Action(
R.drawable.ic_skip_previous_white_24dp,
mService.getString(R.string.label_previous),
MediaButtonReceiver.buildMediaButtonPendingIntent(
mService,
PlaybackStateCompat.ACTION_SKIP_TO_PREVIOUS));
// Cancel all notifications to handle the case where the Service was killed and
// restarted by the system.
mNotificationManager.cancelAll();
}
示例9: onOptionsItemSelected
import android.app.NotificationManager; //导入方法依赖的package包/类
@Override
public boolean onOptionsItemSelected(MenuItem item) {
DbClear dbClear = new DbClear();
int size;
float fontSize;
SharedPreferences mPreferences = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
switch (item.getItemId()) {
case R.id.action_flattr:
Intent intentFlattr = new Intent(Intent.ACTION_VIEW, Uri.parse(FLATTR_LINK));
startActivity(intentFlattr);
break;
case R.id.action_project:
Intent intentProj= new Intent(Intent.ACTION_VIEW, Uri.parse(PROJECT_LINK));
startActivity(intentProj);
break;
case R.id.action_feedsources:
Intent intentfs = new Intent(MainActivity.this, FeedSourcesActivity.class);
intentfs.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
startActivity(intentfs);
break;
case R.id.action_regex:
Intent intentreg = new Intent(MainActivity.this, PrefRegexActivity.class);
intentreg.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
startActivity(intentreg);
break;
case R.id.action_preferences:
Intent intent = new Intent(MainActivity.this, PreferencesActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
startActivity(intent);
break;
case R.id.action_delNotifies:
String ns = Context.NOTIFICATION_SERVICE;
NotificationManager nMgr = (NotificationManager) ctx.getSystemService(ns);
nMgr.cancelAll();
break;
case R.id.action_readedFeeds:
dbClear.execute(R.id.action_readedFeeds);
break;
case R.id.action_delFeeds:
dbClear.execute(R.id.action_delFeeds);
break;
case R.id.action_biggerText:
fontSize = mPreferences.getFloat("font_size", AnotherRSS.Config.DEFAULT_FONT_SIZE);
fontSize = fontSize * 1.1f;
mPreferences.edit().putFloat("font_size", fontSize).apply();
break;
case R.id.action_smallerText:
fontSize = mPreferences.getFloat("font_size", AnotherRSS.Config.DEFAULT_FONT_SIZE);
fontSize = fontSize * 0.9f;
if (fontSize < 3.0f) fontSize = 3.0f;
mPreferences.edit().putFloat("font_size", fontSize).apply();
break;
case R.id.action_biggerImageSize:
size = mPreferences.getInt("image_width", AnotherRSS.Config.DEFAULT_MAX_IMG_WIDTH);
size = size + 20;
mPreferences.edit().putInt("image_width", size).apply();
break;
case R.id.action_smallerImageSize:
size = mPreferences.getInt("image_width", AnotherRSS.Config.DEFAULT_MAX_IMG_WIDTH);
size = size - 10;
if (size < 0) size = 0;
mPreferences.edit().putInt("image_width", size).apply();
break;
default:
break;
}
return true;
}
示例10: reset
import android.app.NotificationManager; //导入方法依赖的package包/类
public void reset() {
logOutApi();
// stop user session
stopUserSession();
// cancel all notification
NotificationManager notifManager = (NotificationManager) mContext.getSystemService(Context.NOTIFICATION_SERVICE);
if (notifManager != null) {
notifManager.cancelAll();
}
}
示例11: onReceive
import android.app.NotificationManager; //导入方法依赖的package包/类
@Override
public void onReceive(Context context, Intent intent) {
active.clear();
cancelAllNotifications();
NotificationManager nm = (NotificationManager)getSystemService(NOTIFICATION_SERVICE);
nm.cancelAll();
}
示例12: clearNotifications
import android.app.NotificationManager; //导入方法依赖的package包/类
public static void clearNotifications(Context context) {
NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.cancelAll();
}
示例13: cancelNotifications
import android.app.NotificationManager; //导入方法依赖的package包/类
public void cancelNotifications(){
NotificationManager nm = (NotificationManager) getSystemService(this.NOTIFICATION_SERVICE);
nm.cancelAll();
}
示例14: clearAllNotifications
import android.app.NotificationManager; //导入方法依赖的package包/类
public static void clearAllNotifications(Context context) {
NotificationManager notificationManager = (NotificationManager)
context.getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.cancelAll();
}
示例15: onCreate
import android.app.NotificationManager; //导入方法依赖的package包/类
@Override
public void onCreate() {
NotificationManager nm = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
nm.cancelAll();
stopSelf();
}