Search in sources :

Example 1 with Notification

use of android.app.Notification in project Android-ReactiveLocation by mcharmas.

the class GeofenceBroadcastReceiver method onReceive.

@Override
public void onReceive(Context context, Intent intent) {
    GeofencingEvent event = GeofencingEvent.fromIntent(intent);
    String transition = mapTransition(event.getGeofenceTransition());
    NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
    Notification notification = new NotificationCompat.Builder(context).setSmallIcon(R.drawable.ic_launcher).setContentTitle("Geofence action").setContentText(transition).setTicker("Geofence action").build();
    nm.notify(0, notification);
}
Also used : NotificationManager(android.app.NotificationManager) NotificationCompat(android.support.v4.app.NotificationCompat) Notification(android.app.Notification) GeofencingEvent(com.google.android.gms.location.GeofencingEvent)

Example 2 with Notification

use of android.app.Notification in project AndroidTraining by mixi-inc.

the class NotificationActivity1 method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_notification1);
    NotificationCompat.Builder builder = new NotificationCompat.Builder(this);
    Notification notification = builder.setSmallIcon(R.drawable.ic_launcher).setContentTitle("通知テスト").setContentText("通知の詳細テスト").setTicker("通知ティッカーテスト").setVibrate(// 3秒間バイブレーションが作動
    new long[] { 3000 }).build();
    NotificationManager manager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
    manager.notify(0, notification);
}
Also used : NotificationManager(android.app.NotificationManager) NotificationCompat(android.support.v4.app.NotificationCompat) Notification(android.app.Notification)

Example 3 with Notification

use of android.app.Notification in project AndroidTraining by mixi-inc.

the class NotificationActivity2 method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_notification2);
    Intent intent = new Intent();
    intent.setAction(ACTION_VIEW_MY_OWN);
    PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
    NotificationCompat.Builder builder = new NotificationCompat.Builder(this);
    Notification notification = builder.setSmallIcon(R.drawable.ic_launcher).setContentTitle("通知テスト").setContentText("通知の詳細テスト").setContentIntent(pendingIntent).build();
    NotificationManager manager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
    manager.notify(0, notification);
}
Also used : NotificationManager(android.app.NotificationManager) NotificationCompat(android.support.v4.app.NotificationCompat) Intent(android.content.Intent) PendingIntent(android.app.PendingIntent) PendingIntent(android.app.PendingIntent) Notification(android.app.Notification)

Example 4 with Notification

use of android.app.Notification in project AndroidTraining by mixi-inc.

the class NotificationActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_notification);
    Intent intent = new Intent(this, NotificationSubActivity.class);
    PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
    NotificationCompat.Builder builder = new NotificationCompat.Builder(this);
    Notification notification = builder.setSmallIcon(R.drawable.ic_launcher).setContentTitle("通知テスト").setContentText("通知の詳細テスト").setContentIntent(// 通知をタップした時に使う PendingIntent
    pendingIntent).setOnlyAlertOnce(// この通知が未だ表示されていない時だけ、音やバイブレーション、ショートメッセージの表示を行う
    true).setAutoCancel(// タップしたら消えるようにする
    true).build();
    NotificationManager manager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
    manager.notify(0, notification);
}
Also used : NotificationManager(android.app.NotificationManager) NotificationCompat(android.support.v4.app.NotificationCompat) Intent(android.content.Intent) PendingIntent(android.app.PendingIntent) PendingIntent(android.app.PendingIntent) Notification(android.app.Notification)

Example 5 with Notification

use of android.app.Notification in project k-9 by k9mail.

the class NewMailNotifications method createStackedNotification.

private void createStackedNotification(Account account, NotificationHolder holder) {
    if (isPrivacyModeEnabled()) {
        return;
    }
    Notification notification = wearNotifications.buildStackedNotification(account, holder);
    int notificationId = holder.notificationId;
    getNotificationManager().notify(notificationId, notification);
}
Also used : Notification(android.app.Notification)

Aggregations

Notification (android.app.Notification)929 PendingIntent (android.app.PendingIntent)458 Intent (android.content.Intent)423 NotificationManager (android.app.NotificationManager)251 NotificationCompat (android.support.v4.app.NotificationCompat)149 StatusBarNotification (android.service.notification.StatusBarNotification)133 Test (org.junit.Test)89 Bitmap (android.graphics.Bitmap)78 Resources (android.content.res.Resources)73 Context (android.content.Context)67 RemoteViews (android.widget.RemoteViews)51 NotificationChannel (android.app.NotificationChannel)33 ITransientNotification (android.app.ITransientNotification)32 RemoteException (android.os.RemoteException)32 SuppressLint (android.annotation.SuppressLint)29 TargetApi (android.annotation.TargetApi)29 Uri (android.net.Uri)29 Config (org.robolectric.annotation.Config)26 SpannableString (android.text.SpannableString)23 NotificationCompat (androidx.core.app.NotificationCompat)23