Notification texts go here Contact Us Buy Now!

Create Notification

final Context context = getApplicationContext(); NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); Intent intent = new Intent(this, MainActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, 0); androidx.core.app.NotificationCompat.Builder builder; int notificationId = 1; String channelId = "channel-01"; String channelName = "Channel Name"; int importance = NotificationManager.IMPORTANCE_HIGH; if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) { NotificationChannel mChannel = new NotificationChannel( channelId, channelName, importance); notificationManager.createNotificationChannel(mChannel); } /* Developer :- androidbulb */ androidx.core.app.NotificationCompat.Builder mBuilder = new androidx.core.app.NotificationCompat.Builder(context, channelId) .setSmallIcon(R.drawable.app_icon) .setContentTitle(_Title) .setContentText(_Content) .setAutoCancel(true) .setOngoing(false) .setContentIntent(pendingIntent); TaskStackBuilder stackBuilder = TaskStackBuilder.create(context); stackBuilder.addNextIntent(intent); PendingIntent resultPendingIntent = stackBuilder.getPendingIntent( 0, PendingIntent.FLAG_UPDATE_CURRENT ); mBuilder.setContentIntent(resultPendingIntent); notificationManager.notify(notificationId, mBuilder.build());

Post a Comment

Cookie Consent
We serve cookies on this site to analyze traffic, remember your preferences, and optimize your experience.
Oops!
It seems there is something wrong with your internet connection. Please connect to the internet and start browsing again.
AdBlock Detected!
We have detected that you are using adblocking plugin in your browser.
The revenue we earn by the advertisements is used to manage this website, we request you to whitelist our website in your adblocking plugin.
Site is Blocked
Sorry! This site is not available in your country.