Search in sources :

Example 71 with Notification

use of android.app.Notification in project android-garage-opener by bradfitz.

the class InRangeService method startScanning.

private void startScanning() {
    Log.d(TAG, "startScanning()");
    if (!isScanning.compareAndSet(false, true)) {
        logToClients("Scanning already running.");
        return;
    }
    forceMobileConnection();
    mTargetSSID = getPrefs().getString(Preferences.KEY_SSID, null);
    Log.d(TAG, "Scanning for SSID: " + mTargetSSID);
    cpuLock.acquire();
    logToClients("Garage wifi scan starting.");
    outOfRangeScanReceived.set(false);
    shouldOpen.set(false);
    Toast.makeText(this, "Garage Scan Started", Toast.LENGTH_SHORT).show();
    Notification n = new Notification();
    n.icon = R.drawable.icon;
    n.flags = Notification.FLAG_NO_CLEAR | Notification.FLAG_ONGOING_EVENT;
    n.setLatestEventInfo(this, "Garage Scanning", "Garage door wifi scan is in progress.", PendingIntent.getActivity(this, 0, new Intent(this, GarageDoorActivity.class), 0));
    notificationManager().cancel(NOTIFY_ID_EVENT);
    notificationManager().notify(NOTIFY_ID_SCANNING, n);
    startForeground(NOTIFY_ID_SCANNING, n);
    wifiLock.acquire();
    registerReceiver(onScanResult, scanResultIntentFilter);
    wifi().startScan();
}
Also used : Intent(android.content.Intent) PendingIntent(android.app.PendingIntent) Notification(android.app.Notification)

Example 72 with Notification

use of android.app.Notification in project WeChatLuckyMoney by geeeeeeeeek.

the class HongbaoService method watchNotifications.

private boolean watchNotifications(AccessibilityEvent event) {
    // Not a notification
    if (event.getEventType() != AccessibilityEvent.TYPE_NOTIFICATION_STATE_CHANGED)
        return false;
    // Not a hongbao
    String tip = event.getText().toString();
    if (!tip.contains(WECHAT_NOTIFICATION_TIP))
        return true;
    Parcelable parcelable = event.getParcelableData();
    if (parcelable instanceof Notification) {
        Notification notification = (Notification) parcelable;
        try {
            /* 清除signature,避免进入会话后误判 */
            signature.cleanSignature();
            notification.contentIntent.send();
        } catch (PendingIntent.CanceledException e) {
            e.printStackTrace();
        }
    }
    return true;
}
Also used : Parcelable(android.os.Parcelable) PendingIntent(android.app.PendingIntent) Notification(android.app.Notification)

Example 73 with Notification

use of android.app.Notification in project XobotOS by xamarin.

the class WifiWatchdogStateMachine method displayDisabledNetworkNotification.

private void displayDisabledNetworkNotification(String ssid) {
    Resources r = Resources.getSystem();
    CharSequence title = r.getText(com.android.internal.R.string.wifi_watchdog_network_disabled);
    String msg = ssid + r.getText(com.android.internal.R.string.wifi_watchdog_network_disabled_detailed);
    Notification wifiDisabledWarning = new Notification.Builder(mContext).setSmallIcon(com.android.internal.R.drawable.stat_sys_warning).setDefaults(Notification.DEFAULT_ALL).setTicker(title).setContentTitle(title).setContentText(msg).setContentIntent(PendingIntent.getActivity(mContext, 0, new Intent(WifiManager.ACTION_PICK_WIFI_NETWORK).setFlags(Intent.FLAG_ACTIVITY_NEW_TASK), 0)).setWhen(System.currentTimeMillis()).setAutoCancel(true).getNotification();
    NotificationManager notificationManager = (NotificationManager) mContext.getSystemService(Context.NOTIFICATION_SERVICE);
    notificationManager.notify(WATCHDOG_NOTIFICATION_ID, 1, wifiDisabledWarning);
    mNotificationShown = true;
}
Also used : NotificationManager(android.app.NotificationManager) Intent(android.content.Intent) PendingIntent(android.app.PendingIntent) Resources(android.content.res.Resources) Notification(android.app.Notification)

Example 74 with Notification

use of android.app.Notification in project WordPress-Android by wordpress-mobile.

the class AnalyticsTrackerMixpanel method showNotification.

@SuppressWarnings("deprecation")
@SuppressLint("NewApi")
public static void showNotification(Context context, PendingIntent intent, int notificationIcon, CharSequence title, CharSequence message) {
    final NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
    final Notification.Builder builder = new Notification.Builder(context).setSmallIcon(notificationIcon).setTicker(message).setWhen(System.currentTimeMillis()).setContentTitle(title).setContentText(message).setContentIntent(intent);
    Notification notification;
    notification = builder.build();
    notification.flags |= Notification.FLAG_AUTO_CANCEL;
    nm.notify(0, notification);
}
Also used : NotificationManager(android.app.NotificationManager) Notification(android.app.Notification) SuppressLint(android.annotation.SuppressLint)

Example 75 with Notification

use of android.app.Notification in project XobotOS by xamarin.

the class AccountManagerService method doNotification.

private void doNotification(Account account, CharSequence message, Intent intent) {
    long identityToken = clearCallingIdentity();
    try {
        if (Log.isLoggable(TAG, Log.VERBOSE)) {
            Log.v(TAG, "doNotification: " + message + " intent:" + intent);
        }
        if (intent.getComponent() != null && GrantCredentialsPermissionActivity.class.getName().equals(intent.getComponent().getClassName())) {
            createNoCredentialsPermissionNotification(account, intent);
        } else {
            final Integer notificationId = getSigninRequiredNotificationId(account);
            intent.addCategory(String.valueOf(notificationId));
            Notification n = new Notification(android.R.drawable.stat_sys_warning, null, 0);
            final String notificationTitleFormat = mContext.getText(R.string.notification_title).toString();
            n.setLatestEventInfo(mContext, String.format(notificationTitleFormat, account.name), message, PendingIntent.getActivity(mContext, 0, intent, PendingIntent.FLAG_CANCEL_CURRENT));
            installNotification(notificationId, n);
        }
    } finally {
        restoreCallingIdentity(identityToken);
    }
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Notification(android.app.Notification)

Aggregations

Notification (android.app.Notification)568 PendingIntent (android.app.PendingIntent)276 Intent (android.content.Intent)253 NotificationManager (android.app.NotificationManager)128 StatusBarNotification (android.service.notification.StatusBarNotification)96 NotificationCompat (android.support.v4.app.NotificationCompat)64 Resources (android.content.res.Resources)56 Bitmap (android.graphics.Bitmap)48 Test (org.junit.Test)48 Context (android.content.Context)47 ITransientNotification (android.app.ITransientNotification)32 RemoteViews (android.widget.RemoteViews)30 RemoteException (android.os.RemoteException)24 ApplicationInfo (android.content.pm.ApplicationInfo)17 UserHandle (android.os.UserHandle)17 Date (java.util.Date)16 Uri (android.net.Uri)15 Bundle (android.os.Bundle)15 ComponentName (android.content.ComponentName)13 File (java.io.File)13