简体   繁体   中英

Set custom icon for cordova-plugin-background-mode

I am trying to set up a custom icon so it no longer shows the white square, but I can't seem to get it to target a new icon. How do i include more icons in my project and aim this plugin to use a new icon?

I tried adding <icon src="<resource-file src="img_res/icons/android/icon_noti.png" target="res/drawable/iconnoti.png" /> to my config

<platform name="android">
    <resource-file src="img_res/icons/android/icon_noti.png" target="res/drawable/iconnoti.png" />
    <icon density="ldpi" src="img_res/icons/android/ldpi.png" />
    <icon density="mdpi" src="img_res/icons/android/mdpi.png" />
    <icon density="hdpi" src="img_res/icons/android/hdpi.png" />
    <icon density="xhdpi" src="img_res/icons/android/xhdpi.png" />
    <icon density="xxhdpi" src="img_res/icons/android/xxhdpi.png" />
    <icon density="xxxhdpi" src="img_res/icons/android/xxxhdpi.png" />
    <splash density="port-ldpi" src="img_res/screens/android/splash-port-ldpi.png" />
    <splash density="port-mdpi" src="img_res/screens/android/splash-port-mdpi.png" />
    <splash density="port-hdpi" src="img_res/screens/android/splash-port-hdpi.png" />
    <splash density="port-xhdpi" src="img_res/screens/android/splash-port-xhdpi.png" />
    <splash density="port-xxhdpi" src="img_res/screens/android/splash-port-xxhdpi.png" />
    <splash density="port-xxxhdpi" src="img_res/screens/android/splash-port-xxxhdpi.png" />
</platform>

And using it like this

cordova.plugins.backgroundMode.setDefaults({
    resume: true,
    hidden: false,
    bigText: false,
    icon:'iconnoti'
});

When I search the platforms folder, it did add the icon to the drawable folder. But I still get the white square. I tried different icons, black on transparent, white on transparent, xxxhdpi size, ldpi size, but always a white square.

I'm a bit lost on this. I don't want to lose the colour icon in the launcher. How do I add an extra icon to the app, and have the plugin use the icon?

Thanks

Try adding the extension to the icon:

cordova.plugins.backgroundMode.setDefaults({
    resume: true,
    hidden: false,
    bigText: false,
    icon:'iconnoti.png'
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM