use of android.app.NotificationManager in project SimplifyReader by chentao0707.
the class DownloadServiceManager method destroy.
public void destroy() {
stopAllTaskNoTips();
NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
nm.cancel(NOTIFY_ID);
}
use of android.app.NotificationManager in project cw-omnibus by commonsguy.
the class ScheduledService method onNoSubscriber.
@Subscribe
public void onNoSubscriber(NoSubscriberEvent event) {
RandomEvent randomEvent = (RandomEvent) event.originalEvent;
NotificationCompat.Builder b = new NotificationCompat.Builder(this);
Intent ui = new Intent(this, EventDemoActivity.class);
b.setAutoCancel(true).setDefaults(Notification.DEFAULT_SOUND).setContentTitle(getString(R.string.notif_title)).setContentText(Integer.toHexString(randomEvent.value)).setSmallIcon(android.R.drawable.stat_notify_more).setTicker(getString(R.string.notif_title)).setContentIntent(PendingIntent.getActivity(this, 0, ui, 0));
NotificationManager mgr = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
mgr.notify(NOTIFY_ID, b.build());
}
use of android.app.NotificationManager in project cw-omnibus by commonsguy.
the class MainActivity method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
NotificationManager mgr = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
mgr.notify(NOTIFY_ID, buildNormal().build());
finish();
}
use of android.app.NotificationManager in project android_frameworks_base by ParanoidAndroid.
the class TrashScreenshot method onReceive.
@Override
public void onReceive(Context context, Intent intent) {
Bundle extras = intent.getExtras();
if (extras == null) {
// We have nothing, abort
return;
}
Uri screenshotUri = Uri.parse(extras.getString(SCREENSHOT_URI));
if (screenshotUri != null) {
context.getContentResolver().delete(screenshotUri, null, null);
}
// Dismiss the notification that brought us here.
NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.cancel(GlobalScreenshot.SCREENSHOT_NOTIFICATION_ID);
}
use of android.app.NotificationManager in project android_frameworks_base by ParanoidAndroid.
the class ConnectivityService method setProvNotificationVisible.
private void setProvNotificationVisible(boolean visible, int networkType, String extraInfo, String url) {
if (DBG) {
log("setProvNotificationVisible: E visible=" + visible + " networkType=" + networkType + " extraInfo=" + extraInfo + " url=" + url);
}
Resources r = Resources.getSystem();
NotificationManager notificationManager = (NotificationManager) mContext.getSystemService(Context.NOTIFICATION_SERVICE);
if (visible) {
CharSequence title;
CharSequence details;
int icon;
Intent intent;
Notification notification = new Notification();
switch(networkType) {
case ConnectivityManager.TYPE_WIFI:
title = r.getString(R.string.wifi_available_sign_in, 0);
details = r.getString(R.string.network_available_sign_in_detailed, extraInfo);
icon = R.drawable.stat_notify_wifi_in_range;
intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
intent.setFlags(Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT | Intent.FLAG_ACTIVITY_NEW_TASK);
notification.contentIntent = PendingIntent.getActivity(mContext, 0, intent, 0);
break;
case ConnectivityManager.TYPE_MOBILE:
case ConnectivityManager.TYPE_MOBILE_HIPRI:
title = r.getString(R.string.network_available_sign_in, 0);
// TODO: Change this to pull from NetworkInfo once a printable
// name has been added to it
details = mTelephonyManager.getNetworkOperatorName();
icon = R.drawable.stat_notify_rssi_in_range;
intent = new Intent(CONNECTED_TO_PROVISIONING_NETWORK_ACTION);
intent.putExtra("EXTRA_URL", url);
intent.setFlags(0);
notification.contentIntent = PendingIntent.getBroadcast(mContext, 0, intent, 0);
break;
default:
title = r.getString(R.string.network_available_sign_in, 0);
details = r.getString(R.string.network_available_sign_in_detailed, extraInfo);
icon = R.drawable.stat_notify_rssi_in_range;
intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
intent.setFlags(Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT | Intent.FLAG_ACTIVITY_NEW_TASK);
notification.contentIntent = PendingIntent.getActivity(mContext, 0, intent, 0);
break;
}
notification.when = 0;
notification.icon = icon;
notification.flags = Notification.FLAG_AUTO_CANCEL;
notification.tickerText = title;
notification.setLatestEventInfo(mContext, title, details, notification.contentIntent);
try {
notificationManager.notify(NOTIFICATION_ID, 1, notification);
} catch (NullPointerException npe) {
loge("setNotificaitionVisible: visible notificationManager npe=" + npe);
npe.printStackTrace();
}
} else {
try {
notificationManager.cancel(NOTIFICATION_ID, 1);
} catch (NullPointerException npe) {
loge("setNotificaitionVisible: cancel notificationManager npe=" + npe);
npe.printStackTrace();
}
}
mIsNotificationVisible = visible;
}
Aggregations