Commit d311f40a authored by Sarath's avatar Sarath
Browse files

Null check for whirlpool service start intent

parent ef3f956e
......@@ -129,24 +129,30 @@ public class WhirlpoolNotificationService extends Service {
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
if(intent.getAction() !=null){
if (Objects.requireNonNull(intent.getAction()).equals(WhirlpoolNotificationService.ACTION_START)) {
Disposable startDisposable = AndroidWhirlpoolWalletService.getInstance()
.startService(getApplicationContext())
.observeOn(AndroidSchedulers.mainThread())
.subscribeOn(Schedulers.io())
.subscribe(this::listenService, er -> {
// start failed
Log.e(TAG, "onStartCommand: ".concat(er.getMessage()));
Toast.makeText(getApplicationContext(), er.getMessage(), Toast.LENGTH_LONG).show();
stopWhirlPoolService();
});
compositeDisposable.add(startDisposable);
} else if (Objects.requireNonNull(intent.getAction()).equals(WhirlpoolNotificationService.ACTION_STOP)) {
this.stopWhirlPoolService();
}
}else{
try {
stopSelf();
}catch (Exception ignored){
if (Objects.requireNonNull(intent.getAction()).equals(WhirlpoolNotificationService.ACTION_START)) {
Disposable startDisposable = AndroidWhirlpoolWalletService.getInstance()
.startService(getApplicationContext())
.observeOn(AndroidSchedulers.mainThread())
.subscribeOn(Schedulers.io())
.subscribe(this::listenService, er -> {
// start failed
Log.e(TAG, "onStartCommand: ".concat(er.getMessage()));
Toast.makeText(getApplicationContext(), er.getMessage(), Toast.LENGTH_LONG).show();
stopWhirlPoolService();
});
compositeDisposable.add(startDisposable);
} else if (Objects.requireNonNull(intent.getAction()).equals(WhirlpoolNotificationService.ACTION_STOP)) {
this.stopWhirlPoolService();
}
}
return START_STICKY;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment