NotificationCompat.Builder deprecated in Android O

It is mentioned in the documentation that the builder method NotificationCompat.Builder(Context context) has been deprecated. And we have to use the constructor which has the channelId parameter: NotificationCompat.Builder(Context context, String channelId) NotificationCompat.Builder Documentation: This constructor was deprecated in API level 26.0.0-beta1. use NotificationCompat.Builder(Context, String) instead. All posted Notifications must specify a NotificationChannel Id. Notification.Builder Documentation: … Read more

How to send parameters from a notification-click to an activity?

Take a look at this guide (creating a notification) and to samples ApiDemos “StatusBarNotifications” and “NotificationDisplay”. For managing if the activity is already running you have two ways: Add FLAG_ACTIVITY_SINGLE_TOP flag to the Intent when launching the activity, and then in the activity class implement onNewIntent(Intent intent) event handler, that way you can access the … Read more

Actionbar notification count icon (badge) like Google has

I am not sure if this is the best solution or not, but it is what I need. Please tell me if you know what is need to be changed for better performance or quality. In my case, I have a button. Custom item on my menu – main.xml <item android:id=”@+id/badge” android:actionLayout=”@layout/feed_update_count” android:icon=”@drawable/shape_notification” android:showAsAction=”always”> </item> … Read more

Push Notifications when app is closed

Yes, it is possible ‘to receive notifications from google cloud message when the application is fully closed’. Infact, A broadcast receiver is the mechanism GCM uses to deliver messages. You need to have implement a BroadcastReceiver and declare it in the AndroidManifest.xml. Please refer to the following code snippet. AndroidManifest.xml <receiver android:name=”.GcmBroadcastReceiver” android:permission=”com.google.android.c2dm.permission.SEND” > <intent-filter> … Read more

Custom notification layouts and text colors

The solution is to use built-in styles. The style you need is called TextAppearance.StatusBar.EventContent in Android 2.3 and Android 4.x. In Android 5.x material notifications use several other styles: TextAppearance.Material.Notification, TextAppearance.Material.Notification.Title, and TextAppearance.Material.Notification.Line2. Just set the appropriate text appearance for the text view, and you will get the necessary colors. If you are interested how … Read more

Best way to serialize an NSData into a hexadeximal string

This is a category applied to NSData that I wrote. It returns a hexadecimal NSString representing the NSData, where the data can be any length. Returns an empty string if NSData is empty. NSData+Conversion.h #import <Foundation/Foundation.h> @interface NSData (NSData_Conversion) #pragma mark – String Conversion – (NSString *)hexadecimalString; @end NSData+Conversion.m #import “NSData+Conversion.h” @implementation NSData (NSData_Conversion) #pragma … Read more

Open application after clicking on Notification

See below code. I am using that and it is opening my HomeActivity. NotificationManager notificationManager = (NotificationManager) context .getSystemService(Context.NOTIFICATION_SERVICE); Notification notification = new Notification(icon, message, when); Intent notificationIntent = new Intent(context, HomeActivity.class); notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); PendingIntent intent = PendingIntent.getActivity(context, 0, notificationIntent, 0); notification.setLatestEventInfo(context, title, message, intent); notification.flags |= Notification.FLAG_AUTO_CANCEL; notificationManager.notify(0, notification);

tech