Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
mmm-rain
AndroidUtilCode
提交
74155c92
A
AndroidUtilCode
项目概览
mmm-rain
/
AndroidUtilCode
与 Fork 源项目一致
从无法访问的项目Fork
通知
4
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
A
AndroidUtilCode
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
74155c92
编写于
10月 29, 2020
作者:
B
Blankj
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
see 10/29 log
上级
573843b4
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
76 addition
and
15 deletion
+76
-15
CHANGELOG.md
CHANGELOG.md
+1
-0
buildSrc/src/main/groovy/Config.groovy
buildSrc/src/main/groovy/Config.groovy
+2
-2
lib/utilcode/README-CN.md
lib/utilcode/README-CN.md
+2
-2
lib/utilcode/README.md
lib/utilcode/README.md
+2
-2
lib/utilcode/src/main/java/com/blankj/utilcode/util/MessengerUtils.java
...rc/main/java/com/blankj/utilcode/util/MessengerUtils.java
+16
-3
lib/utilcode/src/main/java/com/blankj/utilcode/util/ServiceUtils.java
.../src/main/java/com/blankj/utilcode/util/ServiceUtils.java
+53
-6
未找到文件。
CHANGELOG.md
浏览文件 @
74155c92
*
`20/10/29`
[add] Fix MessengerUtils startService IllegalStateException. Publish v1.30.4.
*
`20/10/28`
[add] Fix BusUtils ConcurrentModificationException. Publish v1.30.3.
*
`20/10/27`
[add] Fix AppUtils#getAppSignatures. Add DeviceUtils#isDevelopmentSettingsEnabled. Publish v1.30.2.
*
`20/10/26`
[add] Fix AppUtils#isAppForeground. Publish v1.30.1.
...
...
buildSrc/src/main/groovy/Config.groovy
浏览文件 @
74155c92
...
...
@@ -14,8 +14,8 @@ class Config {
static
compileSdkVersion
=
29
static
minSdkVersion
=
14
static
targetSdkVersion
=
29
static
versionCode
=
1
_030_00
3
static
versionName
=
'1.30.
3
'
// E.g. 1.9.72 => 1,009,072
static
versionCode
=
1
_030_00
4
static
versionName
=
'1.30.
4
'
// E.g. 1.9.72 => 1,009,072
// lib version
static
gradlePluginVersion
=
'3.5.0'
...
...
lib/utilcode/README-CN.md
浏览文件 @
74155c92
...
...
@@ -2,10 +2,10 @@
Gradle:
```
groovy
implementation
'com.blankj:utilcode:1.30.
3
'
implementation
'com.blankj:utilcode:1.30.
4
'
// if u use AndroidX, use the following
implementation
'com.blankj:utilcodex:1.30.
3
'
implementation
'com.blankj:utilcodex:1.30.
4
'
```
...
...
lib/utilcode/README.md
浏览文件 @
74155c92
...
...
@@ -2,10 +2,10 @@
Gradle:
```
groovy
implementation
'com.blankj:utilcode:1.30.
3
'
implementation
'com.blankj:utilcode:1.30.
4
'
// if u use AndroidX, use the following
implementation
'com.blankj:utilcodex:1.30.
3
'
implementation
'com.blankj:utilcodex:1.30.
4
'
```
...
...
lib/utilcode/src/main/java/com/blankj/utilcode/util/MessengerUtils.java
浏览文件 @
74155c92
...
...
@@ -6,6 +6,7 @@ import android.content.ComponentName;
import
android.content.Context
;
import
android.content.Intent
;
import
android.content.ServiceConnection
;
import
android.os.Build
;
import
android.os.Bundle
;
import
android.os.Handler
;
import
android.os.IBinder
;
...
...
@@ -48,8 +49,7 @@ public class MessengerUtils {
Log
.
i
(
"MessengerUtils"
,
"Server service is running."
);
return
;
}
Intent
intent
=
new
Intent
(
Utils
.
getApp
(),
ServerService
.
class
);
Utils
.
getApp
().
startService
(
intent
);
startServiceCompat
(
new
Intent
(
Utils
.
getApp
(),
ServerService
.
class
));
return
;
}
if
(
sLocalClient
==
null
)
{
...
...
@@ -118,13 +118,26 @@ public class MessengerUtils {
}
else
{
Intent
intent
=
new
Intent
(
Utils
.
getApp
(),
ServerService
.
class
);
intent
.
putExtras
(
data
);
Utils
.
getApp
().
startService
(
intent
);
startServiceCompat
(
intent
);
}
for
(
Client
client
:
sClientMap
.
values
())
{
client
.
sendMsg2Server
(
data
);
}
}
private
static
void
startServiceCompat
(
Intent
intent
)
{
try
{
intent
.
setFlags
(
Intent
.
FLAG_INCLUDE_STOPPED_PACKAGES
);
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
O
)
{
Utils
.
getApp
().
startForegroundService
(
intent
);
}
else
{
Utils
.
getApp
().
startService
(
intent
);
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
static
class
Client
{
String
mPkgName
;
...
...
lib/utilcode/src/main/java/com/blankj/utilcode/util/ServiceUtils.java
浏览文件 @
74155c92
...
...
@@ -31,7 +31,7 @@ public final class ServiceUtils {
*
* @return all of the services are running
*/
public
static
Set
getAllRunningServices
()
{
public
static
Set
<
String
>
getAllRunningServices
()
{
ActivityManager
am
=
(
ActivityManager
)
Utils
.
getApp
().
getSystemService
(
Context
.
ACTIVITY_SERVICE
);
List
<
RunningServiceInfo
>
info
=
am
.
getRunningServices
(
0x7FFFFFFF
);
Set
<
String
>
names
=
new
HashSet
<>();
...
...
@@ -61,8 +61,16 @@ public final class ServiceUtils {
* @param cls The service class.
*/
public
static
void
startService
(
@NonNull
final
Class
<?>
cls
)
{
startService
(
new
Intent
(
Utils
.
getApp
(),
cls
));
}
/**
* Start the service.
*
* @param intent The intent.
*/
public
static
void
startService
(
Intent
intent
)
{
try
{
Intent
intent
=
new
Intent
(
Utils
.
getApp
(),
cls
);
intent
.
setFlags
(
Intent
.
FLAG_INCLUDE_STOPPED_PACKAGES
);
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
O
)
{
Utils
.
getApp
().
startForegroundService
(
intent
);
...
...
@@ -96,8 +104,22 @@ public final class ServiceUtils {
* @return {@code true}: success<br>{@code false}: fail
*/
public
static
boolean
stopService
(
@NonNull
final
Class
<?>
cls
)
{
Intent
intent
=
new
Intent
(
Utils
.
getApp
(),
cls
);
return
Utils
.
getApp
().
stopService
(
intent
);
return
stopService
(
new
Intent
(
Utils
.
getApp
(),
cls
));
}
/**
* Stop the service.
*
* @param intent The intent.
* @return {@code true}: success<br>{@code false}: fail
*/
public
static
boolean
stopService
(
@NonNull
Intent
intent
)
{
try
{
return
Utils
.
getApp
().
stopService
(
intent
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
return
false
;
}
}
/**
...
...
@@ -145,8 +167,33 @@ public final class ServiceUtils {
public
static
void
bindService
(
@NonNull
final
Class
<?>
cls
,
@NonNull
final
ServiceConnection
conn
,
final
int
flags
)
{
Intent
intent
=
new
Intent
(
Utils
.
getApp
(),
cls
);
Utils
.
getApp
().
bindService
(
intent
,
conn
,
flags
);
bindService
(
new
Intent
(
Utils
.
getApp
(),
cls
),
conn
,
flags
);
}
/**
* Bind the service.
*
* @param intent The intent.
* @param conn The ServiceConnection object.
* @param flags Operation options for the binding.
* <ul>
* <li>0</li>
* <li>{@link Context#BIND_AUTO_CREATE}</li>
* <li>{@link Context#BIND_DEBUG_UNBIND}</li>
* <li>{@link Context#BIND_NOT_FOREGROUND}</li>
* <li>{@link Context#BIND_ABOVE_CLIENT}</li>
* <li>{@link Context#BIND_ALLOW_OOM_MANAGEMENT}</li>
* <li>{@link Context#BIND_WAIVE_PRIORITY}</li>
* </ul>
*/
public
static
void
bindService
(
@NonNull
final
Intent
intent
,
@NonNull
final
ServiceConnection
conn
,
final
int
flags
)
{
try
{
Utils
.
getApp
().
bindService
(
intent
,
conn
,
flags
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
/**
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录