android: null check intent in onStartCommand
For some reason the type annotations here show @NonNull but that is actually false according to the documentation under service. This may be null if the service is being restarted after its process has gone away, and it had previously returned anything except START_STICKY_COMPATIBILITY.
This commit is contained in:
parent
cb6f61cf37
commit
a0e9dfbec2
|
@ -133,11 +133,11 @@ public class Main extends Service implements Runnable {
|
|||
|
||||
@Override
|
||||
public int onStartCommand(Intent intent, int flags, int startId) {
|
||||
if (Objects.equals(intent.getAction(), SHUTDOWN_ACTION)) {
|
||||
if (intent != null && Objects.equals(intent.getAction(), SHUTDOWN_ACTION)) {
|
||||
stop();
|
||||
} else {
|
||||
start();
|
||||
if (intent.getBooleanExtra("wakelock", false))
|
||||
if (intent != null && intent.getBooleanExtra("wakelock", false))
|
||||
setWakelockEnabled(true);
|
||||
}
|
||||
return START_STICKY;
|
||||
|
|
Loading…
Reference in New Issue