@@ -113,18 +113,20 @@ protected void doStartForeground(Bundle extras) {
113
113
114
114
// Unspecified icon uses default.
115
115
int smallIconId = context .getApplicationInfo ().icon ;
116
- if (!smallIconName .equals ("" )){
117
- int resId = getResources ().getIdentifier (smallIconName , "mipmap" ,
118
- getPackageName ());
119
- if (resId ==0 ) {
120
- resId = getResources ().getIdentifier (smallIconName , "drawable" ,
121
- getPackageName ());
122
- }
123
- if (resId !=0 ) {
124
- smallIconId = resId ;
125
- }
126
- }
127
-
116
+ if (smallIconName != null ) {
117
+ if (!smallIconName .equals ("" )){
118
+ int resId = getResources ().getIdentifier (smallIconName , "mipmap" ,
119
+ getPackageName ());
120
+ if (resId ==0 ) {
121
+ resId = getResources ().getIdentifier (smallIconName , "drawable" ,
122
+ getPackageName ());
123
+ }
124
+ if (resId !=0 ) {
125
+ smallIconId = resId ;
126
+ }
127
+ }
128
+ }
129
+
128
130
if (Build .VERSION .SDK_INT < Build .VERSION_CODES .O ) {
129
131
// This constructor is deprecated
130
132
notification = new Notification (
@@ -143,9 +145,9 @@ protected void doStartForeground(Bundle extras) {
143
145
// https://stackoverflow.com/questions/47531742/startforeground-fail-after-upgrade-to-android-8-1
144
146
String NOTIFICATION_CHANNEL_ID = "org.kivy.p4a" + getServiceId ();
145
147
String channelName = "Background Service" + getServiceId ();
146
- NotificationChannel chan = new NotificationChannel (NOTIFICATION_CHANNEL_ID , channelName ,
148
+ NotificationChannel chan = new NotificationChannel (NOTIFICATION_CHANNEL_ID , channelName ,
147
149
NotificationManager .IMPORTANCE_NONE );
148
-
150
+
149
151
chan .setLightColor (Color .BLUE );
150
152
chan .setLockscreenVisibility (Notification .VISIBILITY_PRIVATE );
151
153
NotificationManager manager = (NotificationManager ) getSystemService (Context .NOTIFICATION_SERVICE );
0 commit comments