本文整理匯總了Java中android.service.notification.StatusBarNotification.getPackageName方法的典型用法代碼示例。如果您正苦於以下問題:Java StatusBarNotification.getPackageName方法的具體用法?Java StatusBarNotification.getPackageName怎麽用?Java StatusBarNotification.getPackageName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.service.notification.StatusBarNotification
的用法示例。
在下文中一共展示了StatusBarNotification.getPackageName方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onNotificationPosted
import android.service.notification.StatusBarNotification; //導入方法依賴的package包/類
@Override
public void onNotificationPosted(StatusBarNotification sbn) {
String pack = sbn.getPackageName();
String ticker = sbn.getNotification().tickerText.toString();
Bundle extras = sbn.getNotification().extras;
String title = extras.getString("android.title");
String text = extras.getCharSequence("android.text").toString();
Log.i("Package",pack);
Log.i("Ticker",ticker);
Log.i("Title",title);
Log.i("Text",text);
Intent msgrcv = new Intent("Msg");
msgrcv.putExtra("package", pack);
msgrcv.putExtra("ticker", ticker);
msgrcv.putExtra("title", title);
msgrcv.putExtra("text", text);
LocalBroadcastManager.getInstance(context).sendBroadcast(msgrcv);
}
示例2: onNotificationPosted
import android.service.notification.StatusBarNotification; //導入方法依賴的package包/類
@Override
public void onNotificationPosted(StatusBarNotification sbn) {
if (AndroidUtils.isVersionKitKat()) {
String pack = sbn.getPackageName();
String ticker = getString(sbn.getNotification().tickerText);
Bundle extras = sbn.getNotification().extras;
String title = "";
String text = "";
if (extras != null) {
title = extras.getString("android.title");
text = getString(extras.getCharSequence("android.text")).toString();
}
Log.i("Package", pack);
Log.i("Ticker", ticker);
Log.i("Title", title);
Log.i("Text", text);
Intent msgrcv = new Intent("Msg");
msgrcv.putExtra("package", pack);
msgrcv.putExtra("ticker", ticker);
msgrcv.putExtra("title", title);
msgrcv.putExtra("text", text);
LocalBroadcastManager.getInstance(context).sendBroadcast(msgrcv);
}
}
示例3: checkAppSwitch
import android.service.notification.StatusBarNotification; //導入方法依賴的package包/類
private boolean checkAppSwitch(OnlineConfig onlineConfig, StatusBarNotification statusBarNotification) {
boolean z = true;
String stringValue = onlineConfig.getStringValue(ConfigKey.CollectionNotificationInfoAppSwitch.getValue(), "b");
if (TextUtils.isEmpty(stringValue)) {
return false;
}
List emptyList = Collections.emptyList();
if (stringValue.length() > 1) {
emptyList = Arrays.asList(stringValue.substring(1).split(";"));
}
String packageName = statusBarNotification.getPackageName();
char charAt = stringValue.charAt(0);
if (charAt != 'b') {
return charAt == 'w' ? emptyList.contains(packageName) : false;
} else {
if (emptyList.contains(packageName)) {
z = false;
}
return z;
}
}
示例4: findExistItem
import android.service.notification.StatusBarNotification; //導入方法依賴的package包/類
private NotificationBarInfoItem findExistItem(StatusBarNotification statusBarNotification) {
if (statusBarNotification == null || statusBarNotification.getPackageName() == null) {
return null;
}
if (CollectionUtils.isEmpty(notificationInfo.getData())) {
return null;
}
CharSequence packageName = statusBarNotification.getPackageName();
int id = statusBarNotification.getId();
for (NotificationBarInfoItem notificationBarInfoItem : notificationInfo.getData()) {
if (id == notificationBarInfoItem.getNotifyId() && TextUtils.equals(packageName, notificationBarInfoItem.getPackageName()) && notificationBarInfoItem.getType() == 1) {
return notificationBarInfoItem;
}
}
return null;
}
示例5: loadAppList
import android.service.notification.StatusBarNotification; //導入方法依賴的package包/類
private void loadAppList() {
needIconUpdate = true;
needTextUpdate = true;
Set<String> addedApps = new HashSet<>();
appList.clear();
for (StatusBarNotification notification : service.getActiveNotifications()) {
String appPackage = notification.getPackageName();
if (addedApps.contains(appPackage)) {
continue;
}
addedApps.add(appPackage);
ApplicationInfo applicationInfo;
try {
applicationInfo = service.getPackageManager().getApplicationInfo(appPackage, 0);
String label = service.getPackageManager().getApplicationLabel(applicationInfo).toString();
appList.add(new InstalledApp(appPackage, label));
} catch (PackageManager.NameNotFoundException ignored) {
}
}
Collections.sort(appList);
}
示例6: handleStatusBarNotification
import android.service.notification.StatusBarNotification; //導入方法依賴的package包/類
private void handleStatusBarNotification(@NonNull StatusBarNotification statusBarNotification, @NonNull String intentAction) {
String packageName = statusBarNotification.getPackageName();
String tickerText = "";
if (statusBarNotification.getNotification().tickerText != null) {
tickerText = statusBarNotification.getNotification().tickerText.toString();
}
Bundle extras = statusBarNotification.getNotification().extras;
String title = extras.getString("android.title");
String text = "";
CharSequence textCharSequence = extras.getCharSequence("android.text");
if (textCharSequence != null) {
text = textCharSequence.toString();
} else {
Logger.getInstance().Warning(TAG, "textCharSequence is null!");
}
Bitmap bitmap = statusBarNotification.getNotification().largeIcon;
Notification.Action[] notificationActions = statusBarNotification.getNotification().actions;
Intent messageReceiveIntent = new Intent(intentAction);
messageReceiveIntent.putExtra(EXTRA_KEY_PACKAGE_NAME, packageName);
messageReceiveIntent.putExtra(EXTRA_KEY_TICKER_TEXT, tickerText);
messageReceiveIntent.putExtra(EXTRA_KEY_TITLE, title);
messageReceiveIntent.putExtra(EXTRA_KEY_TEXT, text);
messageReceiveIntent.putExtra(EXTRA_KEY_NOTIFICATION_ACTIONS, notificationActions);
if (bitmap != null) {
ByteArrayOutputStream stream = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.PNG, 100, stream);
byte[] byteArray = stream.toByteArray();
messageReceiveIntent.putExtra(EXTRA_KEY_ICON, byteArray);
}
LocalBroadcastManager.getInstance(_context).sendBroadcast(messageReceiveIntent);
}
示例7: 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());
}
示例8: onNotificationPosted
import android.service.notification.StatusBarNotification; //導入方法依賴的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);
}
示例9: matchNotificationCode
import android.service.notification.StatusBarNotification; //導入方法依賴的package包/類
private int matchNotificationCode(StatusBarNotification sbn) {
String packageName = sbn.getPackageName();
if(packageName.equals(ApplicationPackageNames.FACEBOOK_PACK_NAME)){
return(InterceptedNotificationCode.FACEBOOK_CODE);
}
else if(packageName.equals(ApplicationPackageNames.FACEBOOK_MESSENGER_PACK_NAME)){
return(InterceptedNotificationCode.FACEBOOK_MESSENGER_CODE);
}
else if(packageName.equals(ApplicationPackageNames.INSTAGRAM_PACK_NAME)){
return(InterceptedNotificationCode.INSTAGRAM_CODE);
}
else if(packageName.equals(ApplicationPackageNames.WHATSAPP_PACK_NAME)){
return(InterceptedNotificationCode.WHATSAPP_CODE);
}
else if(packageName.equals(ApplicationPackageNames.GMAIL_PACK_NAME)){
return(InterceptedNotificationCode.GMAIL_CODE);
}
else{
return(InterceptedNotificationCode.OTHER_NOTIFICATIONS_CODE);
}
}
示例10: loadNotifications
import android.service.notification.StatusBarNotification; //導入方法依賴的package包/類
private List<HistoricalNotificationInfo> loadNotifications() {
final int currentUserId = ActivityManager.getCurrentUser();
try {
StatusBarNotification[] active = mNoMan.getActiveNotifications(
mContext.getPackageName());
StatusBarNotification[] dismissed = mNoMan.getHistoricalNotifications(
mContext.getPackageName(), 50);
List<HistoricalNotificationInfo> list
= new ArrayList<HistoricalNotificationInfo>(active.length + dismissed.length);
for (StatusBarNotification[] resultset
: new StatusBarNotification[][] { active, dismissed }) {
for (StatusBarNotification sbn : resultset) {
final HistoricalNotificationInfo info = new HistoricalNotificationInfo();
info.pkg = sbn.getPackageName();
info.user = sbn.getUserId();
info.icon = loadIconDrawable(info.pkg, info.user, sbn.getNotification().icon);
info.pkgicon = loadPackageIconDrawable(info.pkg, info.user);
info.pkgname = loadPackageName(info.pkg);
if (sbn.getNotification().extras != null) {
info.title = sbn.getNotification().extras.getString(
Notification.EXTRA_TITLE);
if (info.title == null || "".equals(info.title)) {
info.title = sbn.getNotification().extras.getString(
Notification.EXTRA_TEXT);
}
}
if (info.title == null || "".equals(info.title)) {
info.title = sbn.getNotification().tickerText;
}
// still nothing? come on, give us something!
if (info.title == null || "".equals(info.title)) {
info.title = info.pkgname;
}
info.timestamp = sbn.getPostTime();
info.priority = sbn.getNotification().priority;
logd(" [%d] %s: %s", info.timestamp, info.pkg, info.title);
info.active = (resultset == active);
if (info.user == UserHandle.USER_ALL
|| info.user == currentUserId) {
list.add(info);
}
}
}
return list;
} catch (RemoteException e) {
Log.e(TAG, "Cannot load Notifications: ", e);
}
return null;
}
示例11: filter
import android.service.notification.StatusBarNotification; //導入方法依賴的package包/類
private boolean filter(StatusBarNotification sbn) {
String packageName = sbn.getPackageName();
if (!globalEnabled() || !appEnabled(packageName)) {
return false;
}
boolean usingCustomSettings = isUsingCustomSettings(packageName);
SharedPreferences sp;
if (usingCustomSettings) {
sp = getSharedPreferences(getString(R.string.notification_settings_custom), MODE_PRIVATE);
} else {
sp = getSharedPreferences(getString(R.string.notification_settings_global), MODE_PRIVATE);
}
int flags = sbn.getNotification().flags;
if (blockOngoing(sp, packageName, usingCustomSettings) && isOngoing(flags)){
return false;
}
if (blockForeground(sp, packageName, usingCustomSettings) && isForeground(flags)){
return false;
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT_WATCH){
if (blockGroupSummary(sp, packageName, usingCustomSettings) && isGroupSummary(flags)){
return false;
}
if (blockLocalOnly(sp, packageName, usingCustomSettings) && isLocalOnly(flags)){
return false;
}
}
return priorityAllowed(sp, packageName, usingCustomSettings, sbn.getNotification().priority);
}
示例12: onNotificationDataChanged
import android.service.notification.StatusBarNotification; //導入方法依賴的package包/類
@Override
public void onNotificationDataChanged(final StatusBarNotification sbn) {
for (AppInfo ai : mAppSlots) {
if (ai.getPackageName() == null)
continue;
if (sbn == null || sbn.getPackageName() == null ||
sbn.getPackageName().equals(ai.getPackageName())) {
ai.updateIcon();
}
}
}
示例13: 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;
}
示例14: Notification
import android.service.notification.StatusBarNotification; //導入方法依賴的package包/類
public Notification(StatusBarNotification sbn, Context c){
ns = new NotificationSettings(c, sbn.getPackageName());
extractStatusBarNotification(sbn, c);
}
示例15: fromNotification
import android.service.notification.StatusBarNotification; //導入方法依賴的package包/類
public static PackageUserKey fromNotification(StatusBarNotification notification) {
return new PackageUserKey(notification.getPackageName(), notification.getUser());
}