I'm new in flutter so please don't kill me if my question is easy.
notification icon doesn't show like this
I put in this path
\android\app\src\main\res\drawable
here is my code for icon:
final settingsAndroid = AndroidInitializationSettings('app_icon');
final settingsIOS = IOSInitializationSettings(onDidReceiveLocalNotification: (id, title, body, payload) => onSelectNotification(payload));
final settingsIOSgeneral = IOSInitializationSettings(onDidReceiveLocalNotification: (id, title, body, payload) => onSelectNotificationgeneral(payload));
notifications.initialize(InitializationSettings(settingsAndroid, settingsIOS), onSelectNotification: onSelectNotification);
Can Any one help me please how can I preview my icon in notification ?
I did the following and it worked for me:
Create a transparent and white notification icon (you can use the following tool: AndroidAssetStudio )
Download the zip folder, unzip and you'll see it contains a res folder with different drawable folders. Copy and paste the contents of the res folder in "android\app\src\main\res" path
Then open the AndroidManifest.xml file and add the following lines to it:
ic_stat_calendar_today is the name of my notification icon. And each of the drawable folders that have been pasted contain a different size of icon with the same name.
If you want to change the color of the icon then check the above image. Add the metadata tag after the notification icon tag
Go to "android\app\src\main\res\values" and add a colors.xml file
<color name="colorAccent">#00FF00</color>
I have shared this answer in the following Github chain as well- Solution.
This could be because the icon image is not transparent -- Try the notification icon generated from this tool. Also check this question Android Push Notifications: Icon not displaying in notification, white square shown instead
generate a transparent icon and then set the color in AndroidNotificationDetails parameter
You must do three things;
1.follow #user2549980's answer and do samethins step by step but in colors.xml file, you must write encoding="utf-8" with uppercase format, like;
(your notification icon must be copied mipmap folders with same sizes, and you must add that icon name to your AndroidManifest.xml, and it must be transparent icon.)
2.Step; in your local notification init function,
_notificationPlugin=FlutterLocalNotificationsPlugin();
await _notificationPlugin.initialize(
const InitializationSettings(
android: AndroidInitializationSettings('#mipmap/notification_icon'),
iOS: IOSInitializationSettings()
),
onSelectNotification: (payload) async{
},
);
you must change this line #mipmap/icon_name with your icon name.
and I am writing this comment because, this step can be missed easily so, don't forget this step.
(1) You don't have to put them in drawable, you can put them in mipmap (android/src/main/res/mip-map-**dpi folders) if you want.
(2) If you need to test the result, hotreload won't take effect, you have to rebuild to test the result.
Related
I have searched for an answer to this question in many places, but none of the answers satisfies what I really want. There are variations of the solution, but they all go along the lines of the code I have below:
MainFrame() {
ImageIcon logo = new ImageIcon(getClass().getResource("file_path"));
setIconImage(logo.getImage);
//the rest of my code
}
public static void main(String[] args){
MainFrame mf = new MainFrame();
mf.pack();
mf.setVisible(true);
}
Basically, load an image or an image icon from a file, and then call the setIconImage() method from the JFrame. This sets the icon image in the title bar of the window, and also the icon image in the task bar when the app is active. But it does not set the icon image of the app icon. In order to show you more clearly what I mean, please see the image I attached, where I circled the three icons. The one with the Java coffee cup is the one I haven't been able to change.
the taskbar, my app, and the window of my app
Can somebody help me set the image of the app icon itself (not just the task bar and title bar icons)?
I was not able change the image of the jar file itself as it sits inside a directory, as shown in the image attached to my question. However, I was able was to set the icon image of the .exe file when I packaged it with jpackage.
Basically, once I was ready to package my app I entered in Command Prompt, making sure to include the --icon option:
jpackage --input C:\app_files\MyApp --name MyApp --main-jar myapp.jar --main-class main.MainThread --icon C:\app_files\MyApp\logo.ico --win-shortcut --dest C:\Users\Desktop\Apps --runtime-image C:\app_files\my_jre
Note: Here, at least for Windows 10, the icon image must be an .ico file.
the application's logo is PNG,so in android lollipop this icon convert to be a white square. so i need to use another image in JPG format for flutter local notification.
i have two questions:
first:
where should i put this image?
second:
how could i access this image?
the code is :
const AndroidInitializationSettings initializationSettingsAndroid =
AndroidInitializationSettings('#mipmap/ic_launcher');
You should create a new image with size 48x48. You can have it as png as well as long as there is transparency and image itself is white.
Let's call this file ic_notification.png
Navigate to your project root directory. You will find android directory. Expand it see following directory in nested order
app
src
main
res
mipmap
if you don't see mipmap folder or different versions of mipmap folder, like mipmap-xxxdpi or mipmap-hdpi etc, create mipmap folder there and put your icon file in that folder.
On flutter side, replace AndroidInitializationSettings('#mipmap/ic_launcher'); with AndroidInitializationSettings('#mipmap/ic_notification'); (without .png)
You should have different icon for app launcher and notification as they serve different purpose.
I try to use a custom SVG for my GNOME shell extension as status icon in top panel. But the custom icon is never shown, just the widget's label text. And I find no error in log output.
When I try to set a build-in icon like "system-search-symbolic" it works, this icon is shown.
This is my code snippet (the SVG is in an "icons" directory of my extension: /home/myusername/.local/share/gnome-shell/extensions/my-widget#my-widgets/icons/timeclock-16x16.svg):
// ...
let widgetBoxLayout = new St.BoxLayout();
let iconPath = `${Me.path}/icons/timeclock-16x16.svg`;
// just for debug if path is correct
log(`${Me.metadata.name}: Icon path=${iconPath}`);
let gicon = Gio.icon_new_for_string(`${iconPath}`);
let icon = new St.Icon({ gicon: gicon, style_class: 'system-status-icon', icon_size: 16 });
// this works for build-in icon:
//let icon = new St.Icon({ icon_name: 'system-search-symbolic', style_class: 'system-status-icon'});
widgetBoxLayout.add(icon);
widgetBoxLayout.add(this.widgetText);
//...
Maybe it's a problem that there is an "#" char in icon path?
But why no error is logged?
What is the correct code to use a custom icon for status panel?
(I have GNOME Shell 3.30.2)
Oh no! This one of these "fight for weeks alone, finally ask the crowd, suddenly know the solution yourself" cases ...
The icon was actually visible but since I use a dark theme and the icon itself is also dark it was not "visible". I inverted the colors of this icon and now I can see the icon next to my text in top panel.
Now I have to find out which icon to use depending on user's theme, but the original issue is solved.
Maybe this answer helps other developer making same stupid error.
You need to use -symbolic icons to allow automatic theme aware re-colorization of the icons. Just change the file name of the icon to timeclock-symbolic.svg, at least this should be your first step if every other aspect is fine.
I have an app which receives the push notifications and display them even if screen is locked.
Icon shown in notification bar is not correct. My project is developed in flutter and app icon is working fine. Where exactly I need to keep the icon file to show correct icon on notification panel. Please refer image below.
Have you tried adding below code in your AndroidManifest.xml,
<!-- Set custom default icon. This is used when no icon is set for incoming notification messages.
<meta-data
android:name="com.google.firebase.messaging.default_notification_icon"
android:resource="#drawable/ic_stat_ic_notification" />
For more read this
I did the following and it worked for me:
Create a transparent and white notification icon (you can use the following tool: AndroidAssetStudio )
Download the zip folder, unzip and you'll see it contains a res folder with different drawable folders. Copy and paste the contents of the res folder in "android\app\src\main\res" path
Then open the AndroidManifest.xml file and add the following lines to it:
ic_stat_calendar_today is the name of my notification icon. And each of the drawable folders that have been pasted contain a different size of icon with the same name.
If you want to change the color of the icon then check the above image. Add the metadata tag after the notification icon tag
Go to "android\app\src\main\res\values" and add a colors.xml file
<color name="colorAccent">#00FF00</color>
I have shared this answer in the following Github chain as well- Solution.
I was wondering how one could use his own icons in a Flutter-Mapbox plugins' marker?
There's no default marker icon (no provided icon - no marker),
and there's not enough documentation on how to use a custom image.
adding a symbol (marker) is as follows:
mapController.addSymbol(
SymbolOptions(
geometry:LatLng(0.0, 0.0), // location is 0.0 on purpose for this example
iconImage: "pin"
)
);
whereas the IconImage, a String, is the field which should contain the data about the icon (obviously), but the given example repository doesn't clarify the needed parameters (url, path etc.).
Providing a path to the assets doesn't work (unlike other widgets). In the example, they provide the IconImage field the value airport-15, and when running the app, it actually works, but I can't seem to find the resources' location (it's not in #drawables or my assets folder, or any other place in the project)
You have to create a custom style on using MapBox Studio.
Create a new dataset if not already exist
Create tileset
Create new style & select customize basic template
Create new layer, give it a name for example my_sym and add newly created datasource
Then click on type & change it to symbol
Now click on my_sym two times. (first one will close the option menu & second one will open a new menu with symbol properties
Click on icon tab & select new icon. You can also upload your own svg icon.
Click on publish
Click on share it will show you the urls.
Copy the type of url & set styleString property.
For more info follow steps here
https://docs.mapbox.com/help/tutorials/add-points-pt-1/
API reference:
https://docs.mapbox.com/mapbox-gl-js/api/
As of release 0.0.5 it will be possible to load custom icon images for your markers. The idea is to add the icon image to your assets folder (for example: assets/symbols/custom-icon.png). If you specify this image as an asset in your pubspec.yaml and set the iconImage in the SymbolOptions to this path it will be loaded automatically.
Regarding the airport-15, this is an icon provided by the Android implementation of the plugin. It is part of the Maki Icons used in Mapbox. Because these icons are part of the Android implementation you will not find as a Flutter asset or an Android resource of the example app.