phicdy devlog

Androidアプリ開発やその他技術系の記事をたまに書きます

AndroidとかiOSとかモバイル多め。その他技術的なことも書いていきます。

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 f:id:phicdy:20170625152335p:plain f:id:phicdy:20170625152426p:plain
4.2 f:id:phicdy:20170625152440p:plain f:id:phicdy:20170625152453p:plain
4.3 f:id:phicdy:20170625152506p:plain f:id:phicdy:20170625152521p:plain
4.4 f:id:phicdy:20170625152534p:plain f:id:phicdy:20170625152547p:plain
5.0 f:id:phicdy:20170625152601p:plain
5.1 f:id:phicdy:20170625152615p:plain
6.0 f:id:phicdy:20170625152628p:plain
7.0 f:id:phicdy:20170625152647p:plain