Skip to content

Commit

Permalink
fix #2768 smallIconName null can t be compared to String (#2769)
Browse files Browse the repository at this point in the history
* fix #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
  • Loading branch information
brvier authored Mar 18, 2023
1 parent 62e0def commit f7ba012
Showing 1 changed file with 16 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -113,18 +113,20 @@ protected void doStartForeground(Bundle extras) {

// Unspecified icon uses default.
int smallIconId = context.getApplicationInfo().icon;
if (!smallIconName.equals("")){
int resId = getResources().getIdentifier(smallIconName, "mipmap",
getPackageName());
if (resId ==0) {
resId = getResources().getIdentifier(smallIconName, "drawable",
getPackageName());
}
if (resId !=0) {
smallIconId = resId;
}
}

if (smallIconName != null) {
if (!smallIconName.equals("")){
int resId = getResources().getIdentifier(smallIconName, "mipmap",
getPackageName());
if (resId ==0) {
resId = getResources().getIdentifier(smallIconName, "drawable",
getPackageName());
}
if (resId !=0) {
smallIconId = resId;
}
}
}

if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
// This constructor is deprecated
notification = new Notification(
Expand All @@ -143,9 +145,8 @@ protected void doStartForeground(Bundle extras) {
// https://stackoverflow.com/questions/47531742/startforeground-fail-after-upgrade-to-android-8-1
String NOTIFICATION_CHANNEL_ID = "org.kivy.p4a" + getServiceId();
String channelName = "Background Service" + getServiceId();
NotificationChannel chan = new NotificationChannel(NOTIFICATION_CHANNEL_ID, channelName,
NotificationManager.IMPORTANCE_NONE);

NotificationChannel chan = new NotificationChannel(NOTIFICATION_CHANNEL_ID, channelName, NotificationManager.IMPORTANCE_NONE);

chan.setLightColor(Color.BLUE);
chan.setLockscreenVisibility(Notification.VISIBILITY_PRIVATE);
NotificationManager manager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
Expand Down

0 comments on commit f7ba012

Please sign in to comment.