Android Status Bar Icon Size - Using Cordova / Phonegap Push Plugin

I am developing an Android application using Ionic (Cordova + AngularJS). With him I use Push Plugin ( https://github.com/phonegap-build/PushPlugin )

In my Resources Folder I have 6 different Application Icons, from ldpi to xxxhdpi

 <icon src="resources/android/icon/drawable-ldpi-icon.png" density="ldpi"/> <icon src="resources/android/icon/drawable-mdpi-icon.png" density="mdpi"/> <icon src="resources/android/icon/drawable-hdpi-icon.png" density="hdpi"/> <icon src="resources/android/icon/drawable-xhdpi-icon.png" density="xhdpi"/> <icon src="resources/android/icon/drawable-xxhdpi-icon.png" density="xxhdpi"/> <icon src="resources/android/icon/drawable-xxxhdpi-icon.png" density="xxxhdpi"/> 

Now, after I build this, my folder structure with finite resources looks something like this:

 android/res/drawable-ldpi/icon.png android/res/drawable-mdpi/icon.png 

etc.

Now this is great for the app icon on all devices. But if I get Push Notification, the application icon appearing in the status bar is too large, so only the middle of the icon is displayed (only for the first seconds, it seems after that the notification reloads (if I pull for example down the status bar), it is displayed right).

After a little research, I found that the icons that I provided are correct for common application icons, but the icons for the status bar should be in a different dimension, as I found out here: Android status bar expects 25x25dp icons, and recommendations recommend 32x32dp. Who is wrong? (2nd answer)

For example, using my Samsung s5, I turned off the xxhdpi 144 * 144px icon for the same icon in the size of 72 * 72 pixels, and it works. the icon is no longer cut out.


Now to my question: How can I configure these "secondary" icons, which I use for notifications only in the resource folder, without overwriting the original ones?

+6
source share
1 answer

You do not need to be so strict about the size of the image. Place the two icons in the platform / android / res / drawable folder. To display a candy on the navigation panel (for example: small_icon.png), it must be white and without background. And one more - to older versions of Android (for example: large_icon.png).

Open the PushPlugin configuration file located at:

 platforms/android/src/com/plugin/gcm/GCMIntentService.java 

Set the icon path in the NotificationCompat.Builder object:

 .setSmallIcon(com.domain.appName.R.drawable.small_icon) .setLargeIcon(largeIcon) 

The large icon should be raster, so define in front of it:

 import android.graphics.Bitmap; import android.graphics.BitmapFactory; Bitmap largeIcon = BitmapFactory.decodeResource(getResources(), com.domain.appName.R.drawable.large_icon); 

Hope this helps you.

+1
source

Source: https://habr.com/ru/post/988773/


All Articles