当前位置: 首页>>代码示例>>Java>>正文


Java NotificationManager.cancelAll方法代码示例

本文整理汇总了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();
    }
  }
}
 
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:21,代码来源:MessageNotifier.java

示例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());


    }
 
开发者ID:fekracomputers,项目名称:QuranAndroid,代码行数:25,代码来源:CloseApplication.java

示例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);
    }
}
 
开发者ID:quickhybrid,项目名称:quickhybrid-android,代码行数:22,代码来源:RuntimeUtil.java

示例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();
    }
}
 
开发者ID:Jaysaw,项目名称:NovaMusicPlayer,代码行数:25,代码来源:NovaNotificationManager.java

示例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;
    }
}
 
开发者ID:tbolender,项目名称:fefereader,代码行数:26,代码来源:PostListActivity.java

示例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"));

}
 
开发者ID:heipidage,项目名称:GcmForMojo,代码行数:19,代码来源:CurrentUserActivity.java

示例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();
}
 
开发者ID:Magicrafter13,项目名称:1946,代码行数:33,代码来源:GcmPush.java

示例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();
}
 
开发者ID:fendoudebb,项目名称:PlayAndroid,代码行数:40,代码来源:MediaNotificationManager.java

示例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;
}
 
开发者ID:no-go,项目名称:AnotherRSS,代码行数:71,代码来源:MainActivity.java

示例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();
    }
}
 
开发者ID:duyp,项目名称:mvvm-template,代码行数:13,代码来源:UserManager.java

示例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();
}
 
开发者ID:sdrausty,项目名称:buildAPKsApps,代码行数:8,代码来源:ClearService.java

示例12: clearNotifications

import android.app.NotificationManager; //导入方法依赖的package包/类
public static void clearNotifications(Context context) {
    NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
    notificationManager.cancelAll();
}
 
开发者ID:anandwana001,项目名称:Tech-Jalsa,代码行数:5,代码来源:NotificationUtils.java

示例13: cancelNotifications

import android.app.NotificationManager; //导入方法依赖的package包/类
public void cancelNotifications(){
    NotificationManager nm = (NotificationManager) getSystemService(this.NOTIFICATION_SERVICE);
    nm.cancelAll();
}
 
开发者ID:PaulKlinger,项目名称:Sprog-App,代码行数:5,代码来源:MainActivity.java

示例14: clearAllNotifications

import android.app.NotificationManager; //导入方法依赖的package包/类
public static void clearAllNotifications(Context context) {
    NotificationManager notificationManager = (NotificationManager)
            context.getSystemService(Context.NOTIFICATION_SERVICE);
    notificationManager.cancelAll();
}
 
开发者ID:wax911,项目名称:anitrend-app,代码行数:6,代码来源:NotificationDispatcher.java

示例15: onCreate

import android.app.NotificationManager; //导入方法依赖的package包/类
@Override
public void onCreate() {
    NotificationManager nm = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
    nm.cancelAll();
    stopSelf();
}
 
开发者ID:bamless,项目名称:chromium-swe-updater,代码行数:7,代码来源:KillNotificationsService.java


注:本文中的android.app.NotificationManager.cancelAll方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。