Skip to content

Commit f7ba012

Browse files
authored
fix kivy#2768 smallIconName null can t be compared to String (kivy#2769)
* fix kivy#2768 smallIconName null can t be compared to String * fix: Remove Importance None of notification which is modification from my own fork * fix: Readd Importance_NONE in the notification channel as it s also in upstream p4a
1 parent 62e0def commit f7ba012

File tree

1 file changed

+16
-15
lines changed

1 file changed

+16
-15
lines changed

pythonforandroid/bootstraps/common/build/src/main/java/org/kivy/android/PythonService.java

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -113,18 +113,20 @@ protected void doStartForeground(Bundle extras) {
113113

114114
// Unspecified icon uses default.
115115
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+
128130
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
129131
// This constructor is deprecated
130132
notification = new Notification(
@@ -143,9 +145,8 @@ protected void doStartForeground(Bundle extras) {
143145
// https://stackoverflow.com/questions/47531742/startforeground-fail-after-upgrade-to-android-8-1
144146
String NOTIFICATION_CHANNEL_ID = "org.kivy.p4a" + getServiceId();
145147
String channelName = "Background Service" + getServiceId();
146-
NotificationChannel chan = new NotificationChannel(NOTIFICATION_CHANNEL_ID, channelName,
147-
NotificationManager.IMPORTANCE_NONE);
148-
148+
NotificationChannel chan = new NotificationChannel(NOTIFICATION_CHANNEL_ID, channelName, NotificationManager.IMPORTANCE_NONE);
149+
149150
chan.setLightColor(Color.BLUE);
150151
chan.setLockscreenVisibility(Notification.VISIBILITY_PRIVATE);
151152
NotificationManager manager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);

0 commit comments

Comments
 (0)