Fix magic crash
This commit is contained in:
2 files changed
+21
-2
No files matched your search
@@ -217,6 +217,7 @@ public class DownloadService extends Service implements DownloadManager.Download
|
||||
.setAutoCancel(false)
|
||||
.setCategory(NotificationCompat.CATEGORY_PROGRESS)
|
||||
.setColor(getResources().getColor(R.color.colorPrimary))
|
||||
.setColorized(true)
|
||||
.addAction(R.drawable.ic_pause_x24, getString(R.string.stat_download_action_stop_all), piStopAll)
|
||||
.setShowWhen(false)
|
||||
.setChannelId(CHANNEL_ID);
|
||||
@@ -245,6 +246,7 @@ public class DownloadService extends Service implements DownloadManager.Download
|
||||
mDownloadedBuilder = new NotificationCompat.Builder(getApplicationContext(), CHANNEL_ID)
|
||||
.setSmallIcon(android.R.drawable.stat_sys_download_done)
|
||||
.setContentTitle(getString(R.string.stat_download_done_title))
|
||||
.setColor(getResources().getColor(R.color.colorPrimary))
|
||||
.setDeleteIntent(piClear)
|
||||
.setOngoing(false)
|
||||
.setAutoCancel(true)
|
||||
@@ -262,6 +264,7 @@ public class DownloadService extends Service implements DownloadManager.Download
|
||||
.setSmallIcon(R.drawable.ic_stat_alert)
|
||||
.setContentText(getString(R.string.stat_509_alert_title))
|
||||
.setContentText(getString(R.string.stat_509_alert_text))
|
||||
.setColor(getResources().getColor(R.color.colorPrimary))
|
||||
.setAutoCancel(true)
|
||||
.setOngoing(false)
|
||||
.setCategory(NotificationCompat.CATEGORY_ERROR);
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in new issue
Block a user