|
13 | 13 | import android.app.PendingIntent; |
14 | 14 | import android.os.Process; |
15 | 15 | import java.io.File; |
16 | | - |
17 | | -//imports for channel definition |
18 | 16 | import android.app.NotificationManager; |
19 | 17 | import android.app.NotificationChannel; |
20 | 18 | import android.graphics.Color; |
21 | | - |
22 | 19 | import org.qtproject.qt.android.bindings.QtService; |
23 | 20 |
|
24 | 21 | public class PythonService extends QtService implements Runnable { |
@@ -77,7 +74,8 @@ public int onStartCommand(Intent intent, int flags, int startId) { |
77 | 74 | Log.v(TAG, "service exists, do not start again"); |
78 | 75 | return startType(); |
79 | 76 | } |
80 | | - //intent is null if OS restarts a STICKY service |
| 77 | + |
| 78 | + //intent is null if OS restarts a STICKY service |
81 | 79 | if (intent == null) { |
82 | 80 | Context context = getApplicationContext(); |
83 | 81 | intent = getThisDefaultIntent(context, ""); |
@@ -124,24 +122,25 @@ protected void doStartForeground(Bundle extras) { |
124 | 122 | PendingIntent pIntent = PendingIntent.getActivity(context, 0, contextIntent, |
125 | 123 | PendingIntent.FLAG_IMMUTABLE | PendingIntent.FLAG_UPDATE_CURRENT); |
126 | 124 |
|
127 | | - // Unspecified icon uses default. |
128 | | - int smallIconId = context.getApplicationInfo().icon; |
129 | | - if (smallIconName != null) { |
130 | | - if (!smallIconName.equals("")){ |
131 | | - int resId = getResources().getIdentifier(smallIconName, "mipmap", |
132 | | - getPackageName()); |
133 | | - if (resId ==0) { |
134 | | - resId = getResources().getIdentifier(smallIconName, "drawable", |
135 | | - getPackageName()); |
136 | | - } |
137 | | - if (resId !=0) { |
138 | | - smallIconId = resId; |
| 125 | + // Unspecified icon uses default. |
| 126 | + int smallIconId = context.getApplicationInfo().icon; |
| 127 | + |
| 128 | + if (smallIconName != null) { |
| 129 | + if (!smallIconName.equals("")){ |
| 130 | + int resId = getResources().getIdentifier(smallIconName, "mipmap", |
| 131 | + getPackageName()); |
| 132 | + if (resId ==0) { |
| 133 | + resId = getResources().getIdentifier(smallIconName, "drawable", |
| 134 | + getPackageName()); |
| 135 | + } |
| 136 | + if (resId !=0) { |
| 137 | + smallIconId = resId; |
| 138 | + } |
139 | 139 | } |
140 | 140 | } |
141 | | - } |
142 | 141 |
|
143 | | - if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) { |
144 | | - // This constructor is deprecated |
| 142 | + if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) { |
| 143 | + // This constructor is deprecated |
145 | 144 | notification = new Notification( |
146 | 145 | smallIconId, serviceTitle, System.currentTimeMillis()); |
147 | 146 | try { |
@@ -172,6 +171,7 @@ protected void doStartForeground(Bundle extras) { |
172 | 171 | builder.setSmallIcon(smallIconId); |
173 | 172 | notification = builder.build(); |
174 | 173 | } |
| 174 | + |
175 | 175 | startForeground(getServiceId(), notification); |
176 | 176 | } |
177 | 177 |
|
|
0 commit comments