Android通知のバージョンごとのUIの違い
自分用にメモ。以下のコードを実行したときのAndroid OSバージョンごとのUIを調べた。
Intent intent = new Intent(context, MainActivity.class); PendingIntent pi = PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT); Notification notification = new NotificationCompat.Builder(context) .setAutoCancel(true) // Delete notification when user taps .setContentTitle("Test") .setTicker("ticker") // Message when notification shows for ~4.4 .setContentInfo("content info") .setContentText("content text") .setSmallIcon(R.mipmap.ic_launcher) .setLargeIcon(BitmapFactory.decodeResource(context.getResources(), R.mipmap.ic_launcher)) .setContentIntent(pi) .build(); NotificationManager manager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); manager.notify(ID, notification);
- Android 4.4までは通知が表示されるときにTickerの文字が表示される。5.0以上では設定しても無視される。
- Android 5.0からはSmall IconがBig iconの右下に表示される。
- Android 7.0からはContent Infoが表示されない。
Notification | Ticker | |
---|---|---|
4.1 | ||
4.2 | ||
4.3 | ||
4.4 | ||
5.0 | ||
5.1 | ||
6.0 | ||
7.0 |