@@ -74,7 +74,8 @@ public int onStartCommand(Intent intent, int flags, int startId) {
7474 Log .v (TAG , "service exists, do not start again" );
7575 return startType ();
7676 }
77- //intent is null if OS restarts a STICKY service
77+
78+ //intent is null if OS restarts a STICKY service
7879 if (intent == null ) {
7980 Context context = getApplicationContext ();
8081 intent = getThisDefaultIntent (context , "" );
@@ -121,24 +122,25 @@ protected void doStartForeground(Bundle extras) {
121122 PendingIntent pIntent = PendingIntent .getActivity (context , 0 , contextIntent ,
122123 PendingIntent .FLAG_IMMUTABLE | PendingIntent .FLAG_UPDATE_CURRENT );
123124
124- // Unspecified icon uses default.
125- int smallIconId = context .getApplicationInfo ().icon ;
126- if (smallIconName != null ) {
127- if (!smallIconName .equals ("" )){
128- int resId = getResources ().getIdentifier (smallIconName , "mipmap" ,
129- getPackageName ());
130- if (resId ==0 ) {
131- resId = getResources ().getIdentifier (smallIconName , "drawable" ,
132- getPackageName ());
133- }
134- if (resId !=0 ) {
135- 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+ }
136139 }
137140 }
138- }
139141
140- if (Build .VERSION .SDK_INT < Build .VERSION_CODES .O ) {
141- // This constructor is deprecated
142+ if (Build .VERSION .SDK_INT < Build .VERSION_CODES .O ) {
143+ // This constructor is deprecated
142144 notification = new Notification (
143145 smallIconId , serviceTitle , System .currentTimeMillis ());
144146 try {
@@ -169,6 +171,7 @@ protected void doStartForeground(Bundle extras) {
169171 builder .setSmallIcon (smallIconId );
170172 notification = builder .build ();
171173 }
174+
172175 startForeground (getServiceId (), notification );
173176 }
174177
0 commit comments