Forum Posts

sifatahmed
Jan 15, 2022
In Wellness Forum
The latest Android OS version, Android Oreo, released on August 21st right in time with the Great American Eclipse. The latest version was deliciously named following the ritual to name Android OS versions on something sweet. Here are a bunch of prominent Android O features that will catch your eye – 2x Faster – Android O boasts of upto two times faster speed when powering up the OS and apps Background limits – Android O will limit the background tasks for the apps you use the least, thereby freeing up resources for the apps you use regularly Autofill – With your permission, Android O will remember credentials to speed up logins into your favorite apps Picture-in-picture – This feature allows you to see two apps in one screen, so you can do a Whatsapp video call and check your email at the same time. That is cool! Instant Apps – You won’t need to install an app to use it, Instant Apps allow you to use a specific app right from the Chrome browser Notification dots – A small dot will appear on the app’s icon when you receive notifications and with a long press on the app icon, you can have a small view of the notifications right there. Apart from the above eye-catching features, Android Oreo includes many subtle, behind the scene features like improved battery performance, new emojis on the Google keyboard, adaptive icons, background location limits, notification categories/channels, notification snoozing and a smart WiFi assistant. Unlike iOS, Android still does not support GIFs or videos in its Rich Push Notifications. After reading this blog post, you will be able to build push notifications using the latest features of Android O, i.e Notification Channels and Notification Badges in your app. Prerequisites Since Notification channels and badges are the features of the latest Android version, you as a developer will have to update your SDK and Build Tools to the latest versions. The latest SDK tools version is 26.0.2 and the latest Build Tools version is 26.0.1. You will have to make sure that in your build.gradle file, the compileSdkVersion is 26 and buildToolsVersion is 26.0.1 android { compileSdkVersion 26 buildToolsVersion "26.0.1" } Java I am also assuming that your app is using Colombia Phone Numbers List one of Firebase or GCM service providers for push notifications. If not, you can setup your app on Firebase and go through their documentation to use it in your app. Notification Channels Starting with Android O, notification channels allow you to create a custom user-controllable channel for each type of notification you want to display. When you target your app to Android O, you will have to implement one or more notification channels to display notifications to your users. If you don’t target Android O and your app is used on a device running Android O, then it will behave the way as it would on Android Nougat (7.0/7.1.1) or lower. To create a notification channel – Construct a NotificationChannel object with a String ID unique to your app Configure the NotificationChannel object to the settings of your choice like alert sounds, lights and importance. Submit the notification channel to the notification manager. Creating a notification channel with the same name and settings again doesn’t cause any problem, so you can create the notification channels at the launch of your app. if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); String id = "id_product"; // The user-visible name of the channel. CharSequence name = "Product"; // The user-visible description of the channel. String description = "Notifications regarding our products"; int importance = NotificationManager.IMPORTANCE_MAX; NotificationChannel mChannel = new NotificationChannel(id, name, importance); // Configure the notification channel. mChannel.setDescription(description); mChannel.enableLights(true); // Sets the notification light color for notifications posted to this // channel, if the device supports this feature. mChannel.setLightColor(Color.RED); notificationManager.createNotificationChannel(mChannel); } Java Notification Badges The new Android O launched a cool feature called Notification Dots/Badges which show notifications that a user has not dismissed on a long press of the app’s icon. By default, each new notification in a particular channel will increment the number displayed in the long-press menu. You can change the number appearing by setting a number of your choice while building the notification. Android O Push Notification Creating a Push Notification on Android Oreo To create a notification, you will use the NotificationCompat.Builder class. The constructor which was used before took only Context as a parameter, but in Android O, the constructor looks like this – NotificationCompat.Builder(Context context, String channelId) Java We’ll be using Postman to send ourselves a push no
0
0
10
 
sifatahmed
More actions