Skip to content

Commit

Permalink
API Level 25 适配.
Browse files Browse the repository at this point in the history
  • Loading branch information
Da Xing committed Oct 21, 2016
1 parent 7167611 commit 673a9c6
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 10 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
>
思路二:API >= 18,同时启动两个id相同的前台Service,然后再将后启动的Service做stop处理;
//启动前台服务而不显示通知的漏洞在 API Level 25 已修复,大快人心!
//启动前台服务而不显示通知的漏洞已在 API Level 25 修复,大快人心!

前台服务相对于后台服务的优势,除了优先级的提升以外,还有一点:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class WatchDogService extends Service {
* 守护服务,运行在:watch子进程中
*/
private int onStart(Intent intent, int flags, int startId) {
//启动前台服务而不显示通知的漏洞在 API Level 25 已修复,大快人心!
//启动前台服务而不显示通知的漏洞已在 API Level 25 修复,大快人心!
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.N) {
startForeground(sHashCode, new Notification());
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,11 @@ public class WorkService extends Service {
* 5.简单守护开机广播.
*/
private int onStart(Intent intent, int flags, int startId) {
//启动前台服务而不显示通知的漏洞在 API Level 25 已修复,大快人心!
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.N) {
//利用漏洞在 API Level 17 及以下的 Android 系统中,启动前台服务而不显示通知
startForeground(sHashCode, new Notification());
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
//利用漏洞在 API Level 18 及以上的 Android 系统中,启动前台服务而不显示通知
startService(new Intent(this, WorkNotificationService.class));
}
//利用漏洞在 API Level 17 及以下的 Android 系统中,启动前台服务而不显示通知
startForeground(sHashCode, new Notification());
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
//利用漏洞在 API Level 18 及以上的 Android 系统中,启动前台服务而不显示通知
startService(new Intent(this, WorkNotificationService.class));
}

//启动守护服务,运行在:watch子进程中
Expand Down

0 comments on commit 673a9c6

Please sign in to comment.