修正 onStartCommand 可能的 NullPointerException
This commit is contained in:
1 parent
8d1ad9697b
commit
2d9a54bc0e
1 file changed
+9
-2
@@ -68,8 +68,9 @@ public class DownloadService extends Service
|
||||
getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int onStartCommand(Intent intent, int flags, int startId) {
|
||||
private void handleIntent(Intent intent) {
|
||||
if (intent == null)
|
||||
return;
|
||||
|
||||
if (ACTION_STOP.equals(intent.getAction())) {
|
||||
stopCurrentTask();
|
||||
@@ -78,6 +79,12 @@ public class DownloadService extends Service
|
||||
stopAll();
|
||||
mNotifyManager.cancel(DOWNLOAD_NOTIFY_ID);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int onStartCommand(Intent intent, int flags, int startId) {
|
||||
|
||||
handleIntent(intent);
|
||||
|
||||
return START_NOT_STICKY;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user