2014년 11월 17일 월요일

How to Show Big Notification


NotificationManager mNotificationManager = (NotificationManager) context
                .getSystemService(Context.NOTIFICATION_SERVICE);
        Notification notification = new Notification.Builder(this).setContentTitle(decodedMsg).
                setContentText(decodedMsg).setSmallIcon(R.drawable.appicon).build();

        RemoteViews bigContentView = new RemoteViews(context.getPackageName(),
                R.layout.custom_notification);
        bigContentView.setImageViewBitmap(R.id.image, bitmap);
        bigContentView.setTextViewText(R.id.title, decodedMsg);
        bigContentView.setTextViewText(R.id.time, PlusTimeFormatter.doIt());


        //아래 코드가 없으면 notification이 크게 표시안됨
        notification.priority = Notification.PRIORITY_MAX;
        notification.bigContentView = bigContentView;

        Intent notificationIntent = new Intent(context, FWWebViewActivity.class);
        notificationIntent.putExtra(PlusConstants.KEY_URL,
                FWConstants.BANNER_URL_HEAD + detailPageUrl);
        PendingIntent contentIntent = PendingIntent.getActivity(context, 0,
                notificationIntent, 0);
        notification.contentIntent = contentIntent;

        // notification.flags |= Notification.FLAG_NO_CLEAR; // Do not clear the
        // notification
        notification.defaults |= Notification.DEFAULT_LIGHTS; // LED
        notification.defaults |= Notification.DEFAULT_VIBRATE; // Vibration
        notification.defaults |= Notification.DEFAULT_SOUND; // Sound



        mNotificationManager.notify(notificationID, notification);
        notificationID = (notificationID - 1) % 1000 + 9000;

댓글 없음:

댓글 쓰기