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


Java NotificationListenerService类代码示例

本文整理汇总了Java中android.service.notification.NotificationListenerService的典型用法代码示例。如果您正苦于以下问题:Java NotificationListenerService类的具体用法?Java NotificationListenerService怎么用?Java NotificationListenerService使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


NotificationListenerService类属于android.service.notification包,在下文中一共展示了NotificationListenerService类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: activateZenMode

import android.service.notification.NotificationListenerService; //导入依赖的package包/类
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private void activateZenMode() {
    ZenModeChange doNotDistrubChange = Preferences.getEnum(service.getGlobalSettings(), GlobalSettings.TIMED_MUTE_ZEN_CHANGE);

    if (doNotDistrubChange != ZenModeChange.NO_CHANGE) {
        int newZenMode;

        switch (doNotDistrubChange) {
            case ALARMS:
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
                    newZenMode = NotificationListenerService.INTERRUPTION_FILTER_ALARMS;
                } else {
                    newZenMode = NotificationListenerService.INTERRUPTION_FILTER_PRIORITY;
                }
                break;
            case PRIORITY:
                newZenMode = NotificationListenerService.INTERRUPTION_FILTER_PRIORITY;
                break;
            default:
                newZenMode = NotificationListenerService.INTERRUPTION_FILTER_NONE;
        }

        previousZenMode = service.getCurrentInterruptionFilter();
        service.requestInterruptionFilterSafe(newZenMode);
    }
}
 
开发者ID:matejdro,项目名称:WearVibrationCenter,代码行数:27,代码来源:TimedMuteManager.java

示例2: onNotificationPosted

import android.service.notification.NotificationListenerService; //导入依赖的package包/类
@Override
public void onNotificationPosted(StatusBarNotification sbn,
                                 NotificationListenerService.RankingMap rankingMap) {

    if (mForwardOnlyPriorityNotifs) {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP &&
                mInterruptionFilter == INTERRUPTION_FILTER_PRIORITY) {
            String packageName = sbn.getPackageName();
            String rankingKey = null;
            for (String s : rankingMap.getOrderedKeys()) {
                if (s.contains(packageName)) {
                    rankingKey = s;
                    break;
                }
            }

            Ranking ranking = new Ranking();
            if (rankingKey != null && rankingMap.getRanking(rankingKey, ranking)) {
                if (!ranking.matchesInterruptionFilter()) {
                    return;
                }
            }
        }
    }
    onNotificationPosted(sbn);
}
 
开发者ID:abhijitvalluri,项目名称:fitnotifications,代码行数:27,代码来源:NLService.java

示例3: startCountDownActivity

import android.service.notification.NotificationListenerService; //导入依赖的package包/类
private void startCountDownActivity(int timer, long startTimeCurrentTime) {
    NotificationListenerService listenerService = new NotificationListenerService() {
        @Override
        public void onNotificationRemoved(StatusBarNotification sbn) {
            super.onNotificationRemoved(sbn);
        }
    };
    WearableTimer wearableTimer = appData.getTimer(timer);
    Intent intent = new Intent(Constants.START_ACTIVITY, Uri.parse(timer + ""), getApplicationContext(), CountDownActivity.class)
            .putExtra(Constants.TIMER_N, timer)
            .putExtra(Constants.TIMER_NAME, wearableTimer.getName())
            .putExtra(Constants.TIMER_DURATION, wearableTimer.getDuration())
            .putExtra(Constants.TIMER_COLOR, wearableTimer.getColor().color)
            .putExtra(Constants.TIMER_CURRENT_TIME, startTimeCurrentTime)
            .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    startActivity(intent);
}
 
开发者ID:khasang,项目名称:Poti,代码行数:18,代码来源:TimerNotificationService.java

示例4: onInterruptionFilterChanged

import android.service.notification.NotificationListenerService; //导入依赖的package包/类
@Override
public void onInterruptionFilterChanged(final int interruptionFilter) {
    boolean inPriority =
            interruptionFilter != NotificationListenerService.INTERRUPTION_FILTER_ALL;
    SharedPreferences prefs = getSharedPreferences("audio_setting", Context.MODE_PRIVATE);
    AudioManager am = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
    if (BuildConfig.DEBUG) Logger.log("onInterruptionFilterChanged " + interruptionFilter);
    if (inPriority) {
        int currentVolume = am.getStreamVolume(AudioManager.STREAM_MUSIC);
        if (BuildConfig.DEBUG) Logger.log(
                "NotificationListener - in priority mode, current volume: " + currentVolume);
        if (currentVolume > 0) {
            prefs.edit().putInt("media_volume", currentVolume).apply();
            if (BuildConfig.DEBUG)
                Logger.log("NotificationListener - changing STREAM_MUSIC volume to 0");
            am.setStreamVolume(AudioManager.STREAM_MUSIC, 0,
                    AudioManager.FLAG_REMOVE_SOUND_AND_VIBRATE);
        }
    } else {
        if (BuildConfig.DEBUG) Logger.log(
                "NotificationListener - changing STREAM_MUSIC volume to : " +
                        prefs.getInt("media_volume", 128));
        am.setStreamVolume(AudioManager.STREAM_MUSIC, prefs.getInt("media_volume", 128), 0);
    }
}
 
开发者ID:j4velin,项目名称:Media-Priority-Mode,代码行数:26,代码来源:NotificationListener.java

示例5: setSensitive

import android.service.notification.NotificationListenerService; //导入依赖的package包/类
public boolean setSensitive(String pkg, int uid, boolean sensitive) {
    try {
        sINM.setPackageVisibilityOverride(pkg, uid,
                sensitive ? Notification.VISIBILITY_PRIVATE
                        : NotificationListenerService.Ranking.VISIBILITY_NO_OVERRIDE);
        return true;
    } catch (Exception e) {
        Log.w(TAG, "Error calling NoMan", e);
        return false;
    }
}
 
开发者ID:ric96,项目名称:lineagex86,代码行数:12,代码来源:NotificationBackend.java

示例6: getNotificationListenerConfig

import android.service.notification.NotificationListenerService; //导入依赖的package包/类
private static Config getNotificationListenerConfig() {
    final Config c = new Config();
    c.tag = TAG;
    c.setting = Settings.Secure.ENABLED_NOTIFICATION_LISTENERS;
    c.intentAction = NotificationListenerService.SERVICE_INTERFACE;
    c.permission = android.Manifest.permission.BIND_NOTIFICATION_LISTENER_SERVICE;
    c.noun = "notification listener";
    c.warningDialogTitle = R.string.notification_listener_security_warning_title;
    c.warningDialogSummary = R.string.notification_listener_security_warning_summary;
    c.emptyText = R.string.no_notification_listeners;
    return c;
}
 
开发者ID:ric96,项目名称:lineagex86,代码行数:13,代码来源:NotificationAccessSettings.java

示例7: onReceive

import android.service.notification.NotificationListenerService; //导入依赖的package包/类
@Override
public void onReceive(Context context, Intent intent) {
    if (android.os.Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP)
        return;

    if (intent.getAction().equals(ACTION_SET_STATE)) {
        int state = intent.getIntExtra(EXTRA_STATE, 1);
        //INTERRUPTION_FILTER_ALL
        if (state != NotificationListenerService.INTERRUPTION_FILTER_ALL)
            state = NotificationListenerService.INTERRUPTION_FILTER_PRIORITY;
        if (state == getCurrentInterruptionFilter())
            return;

        Log.d(TAG, "Set state: " + state);

        //Also force the audio mode for some devices
        //AudioManager audioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
        //audioManager.setRingerMode(state == INTERRUPTION_FILTER_ALL ? AudioManager.RINGER_MODE_NORMAL : AudioManager.RINGER_MODE_SILENT);
        //requestInterruptionFilter(state);
    }

    if (intent.getAction().equals(ACTION_CONNECTED)) {
        if (mStateTime == 0)
            mStateTime = System.currentTimeMillis();
        int interruptionFilter = getCurrentInterruptionFilter();
        SettingsService.sendState(mGoogleApiClient, interruptionFilter, mStateTime);
        mStateTime = System.currentTimeMillis();
    }
}
 
开发者ID:rkkr,项目名称:wear-dnd-sync,代码行数:30,代码来源:LGHackService.java

示例8: isNotificationFilteredByDoNotInterrupt

import android.service.notification.NotificationListenerService; //导入依赖的package包/类
public boolean isNotificationFilteredByDoNotInterrupt(StatusBarNotification statusBarNotification) {
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
        return true;
    }

    NotificationListenerService.RankingMap rankingMap = service.getCurrentRanking();
    if (rankingMap == null) {
        return false;
    }

    NotificationListenerService.Ranking ranking = new NotificationListenerService.Ranking();
    return rankingMap.getRanking(statusBarNotification.getKey(), ranking) && !ranking.matchesInterruptionFilter();

}
 
开发者ID:matejdro,项目名称:WearVibrationCenter,代码行数:15,代码来源:NotificationProcessor.java

示例9: NotificationHandler

import android.service.notification.NotificationListenerService; //导入依赖的package包/类
public NotificationHandler(NotificationListenerService notificationListener) {
    // Instantiate SQLite3 DB accessor
    mDB = new DB(notificationListener);

    // Save for later
    mNotificationListener = notificationListener;
}
 
开发者ID:eladnava,项目名称:shutapp-android,代码行数:8,代码来源:NotificationHandler.java

示例10: removeNotification

import android.service.notification.NotificationListenerService; //导入依赖的package包/类
@SuppressWarnings("deprecation")
private void removeNotification(String pkg, String tag, int id) {
	NotificationListenerService service = QcpNotificationListenerService.getInstance();
	if(service != null) {
		service.cancelNotification(pkg, tag, id);
	}
	if(mRemoveIntent != null) {
		try {
			mRemoveIntent.send();
		} catch (CanceledException e) {
			Log.e(TAG, "CanceledException while sending remove intent");
		}
	}
}
 
开发者ID:hvmunlimited,项目名称:QuickControlPanel,代码行数:15,代码来源:NotificationViewProvider.java

示例11: getZenModeListenerInterruptionFilter

import android.service.notification.NotificationListenerService; //导入依赖的package包/类
public int getZenModeListenerInterruptionFilter(int mZenMode) {
    switch (mZenMode) {
        case ZEN_MODE_OFF:
            return NotificationListenerService.INTERRUPTION_FILTER_ALL;
        case ZEN_MODE_IMPORTANT_INTERRUPTIONS:
            return NotificationListenerService.INTERRUPTION_FILTER_PRIORITY;
        case ZEN_MODE_NO_INTERRUPTIONS:
            return NotificationListenerService.INTERRUPTION_FILTER_NONE;
        default:
            return NotificationListenerService.INTERRUPTION_FILTER_NONE;
    }
}
 
开发者ID:Tombarr,项目名称:Noyze,代码行数:13,代码来源:Constants.java

示例12: zenModeFromListenerInterruptionFilter

import android.service.notification.NotificationListenerService; //导入依赖的package包/类
private static int zenModeFromListenerInterruptionFilter(int listenerInterruptionFilter) {
    switch (listenerInterruptionFilter) {
        case NotificationListenerService.INTERRUPTION_FILTER_ALL:
            return ZEN_MODE_OFF;
        case NotificationListenerService.INTERRUPTION_FILTER_PRIORITY:
            return ZEN_MODE_IMPORTANT_INTERRUPTIONS;
        case NotificationListenerService.INTERRUPTION_FILTER_NONE:
            return ZEN_MODE_NO_INTERRUPTIONS;
        default:
            return ZEN_MODE_OFF;
    }
}
 
开发者ID:Tombarr,项目名称:Noyze,代码行数:13,代码来源:Constants.java

示例13: RemoteControlLollipop

import android.service.notification.NotificationListenerService; //导入依赖的package包/类
protected RemoteControlLollipop(Context context, Class<? extends NotificationListenerService> clazz) {
    super(context);
    mControllerService = new ComponentName(context, clazz);
    mControllers = new ConcurrentHashMap<>();
    mMediaSessionManager = (MediaSessionManager) context.getSystemService(Context.MEDIA_SESSION_SERVICE);
    mMediaSessionManager.addOnActiveSessionsChangedListener(this, mControllerService);
    mRegistered = true;
}
 
开发者ID:Tombarr,项目名称:Noyze,代码行数:9,代码来源:RemoteControlLollipop.java

示例14: requestInterruptionFilter

import android.service.notification.NotificationListenerService; //导入依赖的package包/类
/** Convenience method for sending an {@link android.content.Intent} with {@link #ACTION_REQUEST_INTERRUPTION_FILTER}. */
@SuppressLint("InlinedApi")
public static void requestInterruptionFilter(final Context context, final int zenMode) {
    boolean a60 = (android.os.Build.VERSION.SDK_INT == 23) && Build.VERSION.RELEASE.equals("6.0");
    if (((android.os.Build.VERSION.SDK_INT >= 21) && (android.os.Build.VERSION.SDK_INT < 23)) || a60) {
        if (isNotificationListenerServiceEnabled(context)) {
            int interruptionFilter = NotificationListenerService.INTERRUPTION_FILTER_ALL;
            switch (zenMode) {
                case ActivateProfileHelper.ZENMODE_ALL:
                    interruptionFilter = NotificationListenerService.INTERRUPTION_FILTER_ALL;
                    break;
                case ActivateProfileHelper.ZENMODE_PRIORITY:
                    interruptionFilter = NotificationListenerService.INTERRUPTION_FILTER_PRIORITY;
                    break;
                case ActivateProfileHelper.ZENMODE_NONE:
                    interruptionFilter = NotificationListenerService.INTERRUPTION_FILTER_NONE;
                    break;
                case ActivateProfileHelper.ZENMODE_ALARMS:
                    interruptionFilter = NotificationListenerService.INTERRUPTION_FILTER_ALARMS;
                    break;
            }
            //Log.e(TAG, "requestInterruptionFilter(" + interruptionFilter + ')');
            Intent request = getInterruptionFilterRequestIntent(interruptionFilter, context);
            context.sendBroadcast(request);
        }
    }
}
 
开发者ID:henrichg,项目名称:PhoneProfiles,代码行数:28,代码来源:PPNotificationListenerService.java

示例15: onListenerConnected

import android.service.notification.NotificationListenerService; //导入依赖的package包/类
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR2)
@Override
public void onListenerConnected(@NonNull NotificationListenerService service) {
    StatusBarNotification[] an = service.getActiveNotifications();
    if (an == null) return;
    NotificationPresenter np = NotificationPresenter.getInstance();
    np.init(service, an);
}
 
开发者ID:AChep,项目名称:AcDisplay,代码行数:9,代码来源:NotificationListenerLollipop.java


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