I'm using one signal within my flutter app and everything is fine except the notifications have no icon ( comes with a default bill icon ).
I have read the documentation for one signal and generated an AssetsImage by Android Studio in PROJECT/android/res/ with name ic_stat_onesignal_default
Then I built the app using the command flutter run --release on a real device and still, the notification comes with default bill icon instead of my app icon!!
Is there some code required in the AndroidManifest.xml file too?
use these tool and upload image that is trnasperts
http://romannurik.github.io/AndroidAssetStudio/icons-notification.html#source.type=image&source.space.trim=1&source.space.pad=0&name=ic_stat_onesignal_default
for onesignal the folders names is drawable-xxxx
so you just download from the tool and extract inside the android\app\src\main\res
Note :-
Starting with Android 5, the OS forces Small Notification Icons to be all white when your app targets Android API 21+. If you don't make a correct icon, it will most likely be displayed as a bell or solid white icon in the status bar.
just do some simple things and it changes your default notification icon. I also face this problem in 2021 but I resolve it
in AndroidManifest.xml
<meta-data
android:name="com.onesignal.messaging.default_notification_icon"
android:resource="#mipmap/ic_stat_onesignal_default" />
in build.gradle
buildTypes {
debug {
defaultConfig {
manifestPlaceholders = [onesignal_app_id : "your onesignal app id put here",
onesignal_google_project_number: "your project number put here"]
}
}
}
put your pic in app/main/res/drawable and also in all mipmap with the name "ic_stat_onesignal_default" ..please must use this name otherwise it's not working ..
Related
I'm trying to add a custom action to the media session's playback state, so it can show an addition button on Android Auto. The code is indeed simple, the button is added and I can receive its callback, but the problem is the button doesn't have an icon:
The code:
val builder = PlaybackStateCompat.Builder()
builder.addCustomAction(
"ACTION_TEST",
"TEST LABEL",
R.drawable.ic_test // I tried vector drawable, png,... nothing works
)
// ...
mediaSession.setPlaybackState(builder.build())
The result: the added button doesn't have an icon, only shows a ripple effect (the circle in the screenshot) when I click it, otherwise it's invisible.
I found out the root cause. It's because Android Studio auto-optimizes the build process to produce minimal APK that can run on current ADB-connected devices.
In my case, AS included only xhdpi resources in the debug APK, therefore Android Audio HeadUnit couldn't load the drawable. Basically, AS silently changed the Gradle config to somewhat like this:
android {
...
productFlavors {
dev {
resConfigs "xhdpi" // <- root cause
}
...
}
}
I can simply run my app from the terminal to get rid of this problem.
If you have the same problem, just ensure the drawable is available for all screen densities (hdpi, xhdpi,...), and check your APK whether it's packaged with resources in all screen densities.
For me, the problem was resolved when I cleared the data of Android App application on my phone.
Was using it to run DHU emulator on desktop. Somehow its caching went awry.
I'm just created .apk file with buildozer.But as i said in topic, can't see any icon on device.Everything works and looks fine in Linux. But in device,all icons are blank. This is my buildozer.init requirements: (my ndk,sdk,minapi,ndk_api values are default)
requirements = python3,kivy==1.11.1,https://github.com/kivymd/KivyMD/archive/master.zip
If i use kivymd==0.104.1, i can see icons in android but can't use some commands like : MDTab.get_tab_list() , MDTab.switch_tab() (I asked that problem before in here.So i have to use master branch version because i need to switch MDTabs after some button clicks.But now,i can't see any icon.Is that bug or can someone help me ? Thank you..
(Last note: Im removing .buildozer file before change requirements versions.)
Set correct dependencies in buildozer.spec- https://github.com/kivymd/KivyMD/commit/df73810cc725e4575c93bc4cbbb72f67ff568dc1
I'm learning Notifications, I use Android Studio 4.0 with latest androidx.core.app.NotificationManagerCompat.
There is a sample code about Notifications in the project user-interface-samples.
I find there are many differents about Notifications between this androidx and previous API.
Must the Notifications style be the one of BigTextStyleNotification, BigPictureStyleNotification, InboxStyleNotification and MessagingStyleNotification ?
Following are the notification styles available :
Notification.BigPictureStyle, Notification.BigTextStyle,
Notification.DecoratedCustomViewStyle, Notification.InboxStyle,
Notification.MediaStyle, Notification.MessagingStyle
You can get more info on this link.
Just for information purposes, to create a notification without hustle and get all predefined formatting in one place, just do the following :
Go to the Project Tab of android studio and right click.
Click on New -> UI Component -> Notification
Enter the required notification name
To call this notification just enter the following :
<NotificationClassName>.createNotification(getApplicationContext());
I have created a new Ionic app and setup the cordova local notifications plugin to have notifications run in the background without the need for an external server such as Google Cloud Messaging using this plugin.
https://github.com/katzer/cordova-plugin-local-notifications
Everything seems to work but for some reason the icon shown in the notification isn't the one that I am setting in the js below - can anyone suggest what is wrong - it does show an icon, (an alarm bell) but it isn't the one that have I specified.
// within my $ionicPlatform.ready
$scope.scheduleSingleNotification = function () {
$cordovaLocalNotification.schedule({
id: 1,
title: 'Warning',
text: 'My first local notification this will stick!',
icon: '../img/github-icon.png'
}).then(function (result) {
console.log('Notification #1 triggered');
});
};
I had same problem few months back but than i have given a hit and trial an it worked for
create the icons of all sizes and copy them to /platforms/android/res/
and respective folders of sizes i hope that will solve problem
An always give the path of img respect to your index file not the file in which your are coding but to the main file in which it's included
Make sure that the icon has a white or transparent background. If you take a look at the documentation:
Android notifications
icons should only be a white-on-transparent background image.
I have a simple Android app (built with Mono for Android), which has a problem with it's icon.
The icon is correct in Launcher and in Task Switcher, but
In Manage Apps and in Task Manager it's displayed a generic Android icon
I've checked the various density resources and the manifest and they all look correct.
(I'm seeing this on a Galaxy S phone and on a Nexus 7)
Most likely you set the icon property for your activities within AndroidManifest.xml, but did not set it for the application.
It occurs to me, that the app icon is somehow being cached in the app manager, so that deinstalling and reinstalling the app does not always change the icon properly. Rebooting the device could help.
Also i found this post very useful: adding application ids in gradle usually solves the problem.
Open "AndroidMenifest.xml" in the Package Explorer and click on the "Application" tab at the bottom. Look at the "icon" field and enter the location for your icon ( Ex: #drawable/iconimage). Next, go into the "AndroidManifest.xml" tab and look for android:icon=, adding the location to that as well (Ex: android:icon="#drawable/iconimage)
Make sure you have the same icon name in both locations!
Oleg and Collin are both right but for completeness - in a Mono app the icon can be set with attributes on the Application object (if you have one):
[Application(Label = "MyAppName", Icon = "#drawable/icon")]
class MyApp: Application
{ ...