1 /* 2 * Copyright (C) 2018 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.server.cts.notifications; 18 19 import android.app.Activity; 20 import android.app.Notification; 21 import android.app.NotificationChannel; 22 import android.app.NotificationManager; 23 import android.content.Context; 24 import android.os.Bundle; 25 import android.util.Log; 26 27 public class NotificationIncidentTestActivity extends Activity { 28 final String TAG = "NotificationIncidentTestActivity"; 29 final String NOTIFICATION_CHANNEL_ID = "LegacyNotificationManagerTest"; 30 final String NOTIFICATION_CHANNEL_NAME = "LegacyNotificationManagerTest"; 31 32 @Override onCreate(Bundle bundle)33 public void onCreate(Bundle bundle) { 34 super.onCreate(bundle); 35 Context context = this; 36 NotificationManager notificationManager = 37 (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); 38 notificationManager.createNotificationChannel( 39 new NotificationChannel( 40 NOTIFICATION_CHANNEL_ID, 41 NOTIFICATION_CHANNEL_NAME, 42 NotificationManager.IMPORTANCE_DEFAULT)); 43 44 final Notification notification = 45 new Notification.Builder(context, NOTIFICATION_CHANNEL_ID) 46 .setSmallIcon(R.drawable.icon_black) 47 .setContentTitle("notify") 48 .setContentText("This is notification ") 49 .build(); 50 notificationManager.notify(1, notification); 51 52 Log.i(TAG, "Notification posted."); 53 } 54 } 55