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();
}
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;
}
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;
}
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);
}
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);
}
}
Aggregations