Androidオーロラがカスタム通知をプッシュ

2559 ワード

    private void showInspectorRecordNotification() {
        RemoteViews customView = new RemoteViews(context.getPackageName(), R.layout.view_custom);
        customView.setTextViewText(R.id.tvName_inspectPlan, planInfo.convertlineId2lineName(context, MyApplication.getInstance().getAppData().getUserId()));
        customView.setTextViewText(R.id.tvTime_inspectPlan, planInfo.getPlanYm());
        customView.setTextViewText(R.id.tvPlanSate_inspectPlan, planInfo.convertstateId2stateText(context));

        NotificationCompat.Builder mBuilder = new Builder(context);
        mBuilder.setContent(customView)
                .setContentIntent(getDefalutIntent(PendingIntent.FLAG_UPDATE_CURRENT))
                .setWhen(System.currentTimeMillis())
                .setTicker("")
                .setPriority(Notification.PRIORITY_DEFAULT)
                .setOngoing(false)
                .setSmallIcon(R.mipmap.icon);
        Notification notify = mBuilder.build();
        notify.contentView = customView;
        notify.flags |= Notification.FLAG_AUTO_CANCEL; //           
        //   id    ,           
        int notifyId = (int) System.currentTimeMillis();
        NotificationManager mNotificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
        mNotificationManager.notify(notifyId, notify);
    }
    @Override
    public void onReceive(Context context, Intent intent) {
        if (null == mNotificationManager) {
            mNotificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
        }

        this.context = context;

        Bundle bundle = intent.getExtras();
        Util.soutLong(TAG, "onReceive - " + intent.getAction());

        if (JPushInterface.ACTION_REGISTRATION_ID.equals(intent.getAction())) {//  
            Util.soutLong(TAG, "JPush      ");
        } else if (JPushInterface.ACTION_MESSAGE_RECEIVED.equals(intent.getAction())) {
            Util.soutLong(TAG, "             ");
            //           
        } else if (JPushInterface.ACTION_NOTIFICATION_RECEIVED.equals(intent.getAction())) {
            Util.soutLong(TAG, "          ");
            //               ,       
        }
    }

効果は可能ですが、送信された通知が1つより大きい場合、2つ目の通知は1つ目の通知を上書きします.1つの通知しか表示されず、いくつかの資料を調べてやっと原因を見つけました.
int notifyId = (int) System.currentTimeMillis();       notifyId             ,