Fix magic crash

This commit is contained in:
NekoInverter committed 2020-10-17 21:05:25 +08:00
1 parent e538b756e6
commit 7a6086e1f3
2 files changed
+21 -2

No files matched your search

@@ -32,7 +32,9 @@ import com.hippo.ehviewer.Settings;
import com.hippo.ehviewer.UrlOpener;
import com.hippo.ehviewer.client.EhClient;
import com.hippo.ehviewer.client.EhRequest;
import com.hippo.ehviewer.client.EhUtils;
import com.hippo.ehviewer.client.data.GalleryInfo;
import com.hippo.ehviewer.client.exception.EhException;
import com.hippo.ehviewer.dao.DownloadLabel;
import com.hippo.ehviewer.download.DownloadManager;
import com.hippo.ehviewer.download.DownloadService;
@@ -148,7 +150,14 @@ public final class CommonOperations {
Intent intent = new Intent(activity, DownloadService.class);
intent.setAction(DownloadService.ACTION_START_RANGE);
intent.putExtra(DownloadService.KEY_GID_LIST, toStart);
activity.startService(intent);
try {
activity.startService(intent);
} catch (Exception e){
// java.lang.IllegalStateException:
// Not allowed to start service Intent { act=start cmp=com.hippo.ehviewer/.download.DownloadService (has extras) }: app is in background uid null
e.printStackTrace();
return ;
}
}
if (toAdd.isEmpty()) {
@@ -176,7 +185,14 @@ public final class CommonOperations {
intent.setAction(DownloadService.ACTION_START);
intent.putExtra(DownloadService.KEY_LABEL, label);
intent.putExtra(DownloadService.KEY_GALLERY_INFO, gi);
activity.startService(intent);
try {
activity.startService(intent);
} catch (Exception e){
// java.lang.IllegalStateException:
// Not allowed to start service Intent { act=start cmp=com.hippo.ehviewer/.download.DownloadService (has extras) }: app is in background uid null
e.printStackTrace();
return ;
}
}
// Notify
activity.showTip(R.string.added_to_download_list, BaseScene.LENGTH_SHORT);