@Test public void testRestartNullIntent() { service.onStartCommand(null, Service.START_FLAG_REDELIVERY, 0); assertThat(shadowOf(service).isStoppedBySelf()).isTrue(); }
@Override public int onStartCommand(Intent intent, int flags, int startId) { if (intent == null) { stopSelf(startId); return START_STICKY; } CacheableWebView webView = new CacheableWebView(this); webView.setWebViewClient(new AdBlockWebViewClient(Preferences.adBlockEnabled(this))); webView.setWebChromeClient(new CacheableWebView.ArchiveClient() { @Override public void onProgressChanged(WebView view, int newProgress) { super.onProgressChanged(view, newProgress); if (newProgress == 100) { stopSelf(startId); } } }); webView.loadUrl(intent.getStringExtra(EXTRA_URL)); return START_STICKY; }
WebCacheService extends Service { @Override public int onStartCommand(Intent intent, int flags, int startId) { if (intent == null) { stopSelf(startId); return START_STICKY; } CacheableWebView webView = new CacheableWebView(this); webView.setWebViewClient(new AdBlockWebViewClient(Preferences.adBlockEnabled(this))); webView.setWebChromeClient(new CacheableWebView.ArchiveClient() { @Override public void onProgressChanged(WebView view, int newProgress) { super.onProgressChanged(view, newProgress); if (newProgress == 100) { stopSelf(startId); } } }); webView.loadUrl(intent.getStringExtra(EXTRA_URL)); return START_STICKY; } }
WebCacheService extends Service { @Override public int onStartCommand(Intent intent, int flags, int startId) { if (intent == null) { stopSelf(startId); return START_STICKY; } CacheableWebView webView = new CacheableWebView(this); webView.setWebViewClient(new AdBlockWebViewClient(Preferences.adBlockEnabled(this))); webView.setWebChromeClient(new CacheableWebView.ArchiveClient() { @Override public void onProgressChanged(WebView view, int newProgress) { super.onProgressChanged(view, newProgress); if (newProgress == 100) { stopSelf(startId); } } }); webView.loadUrl(intent.getStringExtra(EXTRA_URL)); return START_STICKY; }  }
WebCacheService extends Service { @Override public int onStartCommand(Intent intent, int flags, int startId) { if (intent == null) { stopSelf(startId); return START_STICKY; } CacheableWebView webView = new CacheableWebView(this); webView.setWebViewClient(new AdBlockWebViewClient(Preferences.adBlockEnabled(this))); webView.setWebChromeClient(new CacheableWebView.ArchiveClient() { @Override public void onProgressChanged(WebView view, int newProgress) { super.onProgressChanged(view, newProgress); if (newProgress == 100) { stopSelf(startId); } } }); webView.loadUrl(intent.getStringExtra(EXTRA_URL)); return START_STICKY; }  @Nullable @Override IBinder onBind(Intent intent); @Override int onStartCommand(Intent intent, int flags, int startId); }
WebCacheService extends Service { @Override public int onStartCommand(Intent intent, int flags, int startId) { if (intent == null) { stopSelf(startId); return START_STICKY; } CacheableWebView webView = new CacheableWebView(this); webView.setWebViewClient(new AdBlockWebViewClient(Preferences.adBlockEnabled(this))); webView.setWebChromeClient(new CacheableWebView.ArchiveClient() { @Override public void onProgressChanged(WebView view, int newProgress) { super.onProgressChanged(view, newProgress); if (newProgress == 100) { stopSelf(startId); } } }); webView.loadUrl(intent.getStringExtra(EXTRA_URL)); return START_STICKY; }  @Nullable @Override IBinder onBind(Intent intent); @Override int onStartCommand(Intent intent, int flags, int startId);  }