Search in sources :

Example 11 with NotificationManager

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);
}
Also used : NotificationManager(android.app.NotificationManager)

Example 12 with NotificationManager

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());
}
Also used : NotificationManager(android.app.NotificationManager) NotificationCompat(android.support.v4.app.NotificationCompat) Intent(android.content.Intent) PendingIntent(android.app.PendingIntent) RandomEvent(com.commonsware.android.parcelable.marshall.RandomEvent) Subscribe(org.greenrobot.eventbus.Subscribe)

Example 13 with NotificationManager

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();
}
Also used : NotificationManager(android.app.NotificationManager)

Example 14 with NotificationManager

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);
}
Also used : NotificationManager(android.app.NotificationManager) Bundle(android.os.Bundle) Uri(android.net.Uri)

Example 15 with NotificationManager

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;
}
Also used : NotificationManager(android.app.NotificationManager) PendingIntent(android.app.PendingIntent) Intent(android.content.Intent) Resources(android.content.res.Resources) Notification(android.app.Notification)

Aggregations

NotificationManager (android.app.NotificationManager)374 Intent (android.content.Intent)187 PendingIntent (android.app.PendingIntent)184 Notification (android.app.Notification)147 NotificationCompat (android.support.v4.app.NotificationCompat)107 Context (android.content.Context)32 Bitmap (android.graphics.Bitmap)24 Uri (android.net.Uri)23 Resources (android.content.res.Resources)22 TaskStackBuilder (android.support.v4.app.TaskStackBuilder)20 TaskStackBuilder (android.app.TaskStackBuilder)15 Bundle (android.os.Bundle)15 StatusBarNotification (android.service.notification.StatusBarNotification)15 Random (java.util.Random)14 BitmapFactory (android.graphics.BitmapFactory)13 SharedPreferences (android.content.SharedPreferences)12 ComponentName (android.content.ComponentName)10 IntentFilter (android.content.IntentFilter)9 ArrayList (java.util.ArrayList)9 Date (java.util.Date)9