The answer to the previous question:
I just use a custom notification in my systemTray system when I wake up incomingActivity.In onCreate () I create customNotification and then I clear Customnotification when IncomingActivity goes onDestroy ().
I use the code below, followed by the format of the method, to create a CustomNotification:
public void setNoticationAfterCallAttendedView(Context view, String callerName, String status,Bitmap bitmap) { Intent notificationIntent = new Intent(view, IncomingCallActivity.class); NotificationCompat.Builder builder = new NotificationCompat.Builder(view) .setSmallIcon(R.drawable.logo,3) .setContentTitle(callerName) .setOngoing(true) .setLargeIcon(bitmap) .setContentText(status) ; PendingIntent contentIntent = PendingIntent.getActivity(view, 0, notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT); builder.setContentIntent(contentIntent); NotificationManager manager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); manager.notify(10000, builder.build()); }
i use the code below followed by the format of the method to clear CustomNotification:
public void clearNotification() { if(this!=null) { NotificationManager manager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); manager.cancel(10000); } }
I hope this solution helps someone. Each Android architecture is different, so I use this format.
Thanks.
source share