anahita zamani
anahita zamani

Reputation: 11

Android RemoteView notificaiton not show again after swipe up

I'm using remote view to make custome notificaiton when phone ringing; if i dismis notificaiton by swiping left or right it is ok. but if i remove notificaiton using swipe up for next call notificaiton not show.

public void notificationCallRinging( CallData callData) {

    int id = createRandomCode(3);

    RemoteViews mremoteViews;

    mid = id;
    Context context = ApplicationController.getAppContext();
    mremoteViews = new RemoteViews(context.getPackageName(), R.layout.custom_notification);
    if (callData.getName() == null || callData.getName().equals("")) {
        mremoteViews.setTextViewText(R.id.tv_fullname, "Unknown");

    } else {
        mremoteViews.setTextViewText(R.id.tv_fullname, callData.getName());

    }
    mremoteViews.setTextViewText(R.id.tv_nnumber, callData.getNumber());

    Intent intent = new Intent(context, CallActivity.class);
    Intent intentAnswer = new Intent(context, CallNotifiBr.class);
    intentAnswer.setAction("answer");

    Intent intentReject = new Intent(context, CallNotifiBr.class);
    intentReject.setAction("reject");

    Intent intentCancel = new Intent(context, CallNotifiBr.class);
    intentCancel.setAction("cancel");

    Intent intentInfo = new Intent(context, CallNotifiBr.class);
    intentInfo.setAction("info");


    NotificationManagerCompat notificationManagerComp = NotificationManagerCompat.from(context);
    String NOTIFICATION_CHANNEL_ID = Util.CALL_RINGING_FOURGROUND_CHANNEL_ID;

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
        @SuppressLint("WrongConstant") NotificationChannel notificationChannel = new NotificationChannel(NOTIFICATION_CHANNEL_ID, "My Notificatigons", NotificationManager.IMPORTANCE_MAX);

        // Configure the notification channel.
        notificationChannel.setDescription("Channegl description");
        notificationChannel.enableLights(true);
        notificationChannel.setLightColor(Color.RED);
        notificationChannel.setVibrationPattern(null);
        notificationChannel.enableVibration(false);
        notificationChannel.setImportance(NotificationManager.IMPORTANCE_MAX);


        notificationManagerComp.createNotificationChannel(notificationChannel);
    }


    PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
    PendingIntent aPendingIntent = PendingIntent.getBroadcast(context, 0, intentAnswer, 0);
    PendingIntent rPendingIntent = PendingIntent.getBroadcast(context, 0, intentReject, 0);
    PendingIntent cPendingIntent = PendingIntent.getBroadcast(context, 0, intentCancel, 0);
    PendingIntent ipendingIntent = PendingIntent.getBroadcast(context, 0, intentInfo, 0);
    PendingIntent pendingtest = PendingIntent.getBroadcast(context, 0, intentInfo, 0);


    mremoteViews.setOnClickPendingIntent(R.id.rtl_call_answear, aPendingIntent);
    mremoteViews.setOnClickPendingIntent(R.id.rtl_call_down, rPendingIntent);
    mremoteViews.setOnClickPendingIntent(R.id.iv_info, ipendingIntent);

    NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(context, Util.CALL_RINGING_FOURGROUND_CHANNEL_ID);
    notificationBuilder.setSmallIcon(R.drawable.palphone_call_icon)
            .setContentTitle("Incoming call")
            .setDeleteIntent(cPendingIntent)
            .setCustomContentView(mremoteViews)
            .setCustomBigContentView(mremoteViews)
            .setContentIntent(pendingtest)
            .setCustomHeadsUpContentView(mremoteViews)
            .setPriority(NotificationCompat.PRIORITY_HIGH)
            .setCategory(NotificationCompat.CATEGORY_CALL)
            .setVibrate(null)
            .setAutoCancel(true)
            .setOngoing(false);

          //   Set notification content intent to take user to the fullscreen UI if user taps on the notification body.
           // .setContentIntent(pendingIntent)
          //   Set full screen intent to trigger display of the fullscreen UI when the notification
           // .setFullScreenIntent(pendingIntent, true);
    Notification notification = notificationBuilder.build();
    notification.flags = Notification.FLAG_INSISTENT | Notification.FLAG_AUTO_CANCEL;

    notification.deleteIntent = pendingIntent;
    notificationManagerComp.notify(11, notification);
    



}

Call one -> notification show -> swipe left or right -> Call two notificaiton show.

// Call one -> notification show -> swipe up -> Call two notificaiton not show

Upvotes: 1

Views: 100

Answers (0)

Related Questions