Skip to content

Commit 5dfb5b8

Browse files
committed
Guard statement on setSmallIcon for android version lower than 6
1 parent faaab1c commit 5dfb5b8

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

android_notify/sword.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
import traceback
33
import os,re
44
import threading
5+
6+
57
from .an_types import Importance
68
from .an_utils import can_accept_arguments
79
from .styles import NotificationStyles
@@ -32,7 +34,7 @@
3234
IconCompat = autoclass('androidx.core.graphics.drawable.IconCompat')
3335
ON_ANDROID = True
3436
except Exception as e:
35-
if e.name != 'android':
37+
if hasattr(e,'name') and e.name != 'android':
3638
print('Exception: ',e)
3739
print(traceback.format_exc())
3840

@@ -537,7 +539,7 @@ def __dispatch_notification(self):
537539
print('Permission not granted to send notifications')
538540
# Not asking for permission too frequently, This makes dialog popup to stop showing
539541
# NotificationHandler.asks_permission()
540-
542+
541543
def __start_notification_build(self, persistent, close_on_click):
542544
self.__create_basic_notification(persistent, close_on_click)
543545
if self.style not in ['simple','']:
@@ -562,7 +564,8 @@ def __create_basic_notification(self, persistent, close_on_click):
562564
self.__built_parameter_filled = True
563565

564566
def __insert_app_icon(self,path=''):
565-
if path or self.app_icon not in ['','Defaults to package app icon']:
567+
if BuildVersion.SDK_INT >= 23 and (path or self.app_icon not in ['','Defaults to package app icon']):
568+
# Bitmap Insert as Icon Not available below Android 6
566569
if self.logs:
567570
print('getting custom icon...')
568571
self.__set_icon_from_bitmap(path or self.app_icon)

0 commit comments

Comments
 (0)