本文整理匯總了Java中android.service.notification.StatusBarNotification.getTag方法的典型用法代碼示例。如果您正苦於以下問題:Java StatusBarNotification.getTag方法的具體用法?Java StatusBarNotification.getTag怎麽用?Java StatusBarNotification.getTag使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.service.notification.StatusBarNotification
的用法示例。
在下文中一共展示了StatusBarNotification.getTag方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: notificationFromStatusBarNotification
import android.service.notification.StatusBarNotification; //導入方法依賴的package包/類
@TargetApi(21)
Notification notificationFromStatusBarNotification(StatusBarNotification sbn) {
if (VERSION.SDK_INT < 21) {
return new Notification(sbn.getPackageName(), sbn.getId(), sbn.getTag(), null, sbn.getNotification());
}
return new Notification(sbn.getPackageName(), sbn.getId(), sbn.getTag(), sbn.getKey(), sbn.getNotification());
}
示例2: containsSameNotification
import android.service.notification.StatusBarNotification; //導入方法依賴的package包/類
public boolean containsSameNotification(StatusBarNotification other) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT_WATCH) {
return contentNotification.getKey().equals(other.getKey());
} else {
return (contentNotification.getPackageName().equals(other.getPackageName()) &&
(contentNotification.getId() == other.getId()) &&
((contentNotification.getTag() != null && contentNotification.getTag().equals(other.getTag())) || (contentNotification.getTag() == null && other.getTag() == null)));
}
}
示例3: getIdentifier
import android.service.notification.StatusBarNotification; //導入方法依賴的package包/類
private String getIdentifier(StatusBarNotification statusBarNotif) {
if (statusBarNotif == null) return null;
String pkgName = statusBarNotif.getPackageName();
if (SUPPORTED_PACKAGES.get(0).equals(pkgName)) {
String tag = statusBarNotif.getTag();
if (tag != null && tag.contains(":")) {
return pkgName + ":" + tag.substring(tag.indexOf(":")+1);
}
if (DEBUG) log("getIdentifier: Unexpected notification tag: " + tag);
} else {
return (pkgName + ":" + String.valueOf(statusBarNotif.getId()));
}
return null;
}
示例4: onNotificationPosted
import android.service.notification.StatusBarNotification; //導入方法依賴的package包/類
@TargetApi(20)
@Override
public void onNotificationPosted(StatusBarNotification sbn, NotificationListenerService.RankingMap rankingMap) {
TITLE = sbn.getNotification().extras.getCharSequence(Notification.EXTRA_TITLE).toString();
//Log.e("GROUP KEY", " " + sbn.getPostTime());
//Log.e("FROM", sbn.getNotification().contentIntent.getCreatorPackage());
if(sbn.getTag() == null && TITLE != null){
notificationCount = sbn.getNotification().number;
notificationCount++;
}else if ((sbn.getTag() != null) && Utilities.isAllowNotificationCountPrefEnabled(getApplicationContext())) {
/*if((sbn.getTag() == null || TITLE != null)){
names.add(TITLE);
try {
icons.add(sbn.getNotification().getLargeIcon().loadDrawable(getApplicationContext()));
}catch (Exception e){
Drawable drawable = new BitmapDrawable(getResources(), Launcher.getIcons().get(sbn.getPackageName()));
icons.add(drawable);
}
}else {
try {
TITLE = sbn.getNotification().extras.getCharSequence(Notification.EXTRA_TITLE).toString();
names.add(TITLE + "\n" + sbn.getNotification().extras.getCharSequence(Notification.EXTRA_TEXT).toString());
icons.add(sbn.getNotification().getLargeIcon().loadDrawable(getApplicationContext()));
} catch (Exception e) {
}
}*/
/*if(sbn.getTag() != null && Utilities.isAllowNotificationCountPrefEnabled(getApplicationContext())) {
notificationCount++;
}else if(sbn.getTag() == null && Utilities.isAllowNotificationCountPrefEnabled(getApplicationContext())
&& TITLE != null){
notificationCount++;
}
*/
notificationCount = sbn.getNotification().number;
notificationCount++;
for (final AppInfo app : AllAppsList.data) {
if (sbn.getPackageName().equals(app.getTargetComponent().getPackageName())) {
if(getNotificationCount(getApplicationContext(), app.getTargetComponent().getPackageName()) != -1){
int notificationCountPrev = getNotificationCount(getApplicationContext(), app.getTargetComponent().getPackageName());
notificationCountPrev++;
setNotificationCount(getApplicationContext(), app.getTargetComponent().getPackageName(), notificationCountPrev);
}else {
setNotificationCount(getApplicationContext(), app.getTargetComponent().getPackageName(), notificationCount);
}
Launcher.getLauncherAppState().reloadWorkspace();
}
}
}
}