Skip to content

Commit 4a8e57a

Browse files
committed
see 03/03 log
1 parent 81c3bab commit 4a8e57a

File tree

1 file changed

+29
-27
lines changed

1 file changed

+29
-27
lines changed

utilcode/src/main/java/com/blankj/utilcode/util/ServiceUtils.java

Lines changed: 29 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
* author: Blankj
1717
* blog : http://blankj.com
1818
* time : 2016/08/02
19-
* desc : 服务相关工具类
19+
* desc : utils about service
2020
* </pre>
2121
*/
2222
public final class ServiceUtils {
@@ -26,11 +26,11 @@ private ServiceUtils() {
2626
}
2727

2828
/**
29-
* 获取所有运行的服务
29+
* Return all of the services are running.
3030
*
31-
* @return 服务名集合
31+
* @return all of the services are running
3232
*/
33-
public static Set getAllRunningService() {
33+
public static Set getAllRunningServices() {
3434
ActivityManager am =
3535
(ActivityManager) Utils.getApp().getSystemService(Context.ACTIVITY_SERVICE);
3636
if (am == null) return Collections.emptySet();
@@ -44,9 +44,9 @@ public static Set getAllRunningService() {
4444
}
4545

4646
/**
47-
* 启动服务
47+
* Start the service.
4848
*
49-
* @param className 完整包名的服务类名
49+
* @param className The name of class.
5050
*/
5151
public static void startService(final String className) {
5252
try {
@@ -57,20 +57,20 @@ public static void startService(final String className) {
5757
}
5858

5959
/**
60-
* 启动服务
60+
* Start the service.
6161
*
62-
* @param cls 服务类
62+
* @param cls The service class.
6363
*/
6464
public static void startService(final Class<?> cls) {
6565
Intent intent = new Intent(Utils.getApp(), cls);
6666
Utils.getApp().startService(intent);
6767
}
6868

6969
/**
70-
* 停止服务
70+
* Stop the service.
7171
*
72-
* @param className 完整包名的服务类名
73-
* @return {@code true}: 停止成功<br>{@code false}: 停止失败
72+
* @param className The name of class.
73+
* @return {@code true}: success<br>{@code false}: fail
7474
*/
7575
public static boolean stopService(final String className) {
7676
try {
@@ -82,23 +82,24 @@ public static boolean stopService(final String className) {
8282
}
8383

8484
/**
85-
* 停止服务
85+
* Stop the service.
8686
*
87-
* @param cls 服务类
88-
* @return {@code true}: 停止成功<br>{@code false}: 停止失败
87+
* @param cls The name of class.
88+
* @return {@code true}: success<br>{@code false}: fail
8989
*/
9090
public static boolean stopService(final Class<?> cls) {
9191
Intent intent = new Intent(Utils.getApp(), cls);
9292
return Utils.getApp().stopService(intent);
9393
}
9494

9595
/**
96-
* 绑定服务
96+
* Bind the service.
9797
*
98-
* @param className 完整包名的服务类名
99-
* @param conn 服务连接对象
100-
* @param flags 绑定选项
98+
* @param className The name of class.
99+
* @param conn The ServiceConnection object.
100+
* @param flags Operation options for the binding.
101101
* <ul>
102+
* <li>0</li>
102103
* <li>{@link Context#BIND_AUTO_CREATE}</li>
103104
* <li>{@link Context#BIND_DEBUG_UNBIND}</li>
104105
* <li>{@link Context#BIND_NOT_FOREGROUND}</li>
@@ -118,12 +119,13 @@ public static void bindService(final String className,
118119
}
119120

120121
/**
121-
* 绑定服务
122+
* Bind the service.
122123
*
123-
* @param cls 服务类
124-
* @param conn 服务连接对象
125-
* @param flags 绑定选项
124+
* @param cls The service class.
125+
* @param conn The ServiceConnection object.
126+
* @param flags Operation options for the binding.
126127
* <ul>
128+
* <li>0</li>
127129
* <li>{@link Context#BIND_AUTO_CREATE}</li>
128130
* <li>{@link Context#BIND_DEBUG_UNBIND}</li>
129131
* <li>{@link Context#BIND_NOT_FOREGROUND}</li>
@@ -140,19 +142,19 @@ public static void bindService(final Class<?> cls,
140142
}
141143

142144
/**
143-
* 解绑服务
145+
* Unbind the service.
144146
*
145-
* @param conn 服务连接对象
147+
* @param conn The ServiceConnection object.
146148
*/
147149
public static void unbindService(final ServiceConnection conn) {
148150
Utils.getApp().unbindService(conn);
149151
}
150152

151153
/**
152-
* 判断服务是否运行
154+
* Return whether service is running.
153155
*
154-
* @param className 完整包名的服务类名
155-
* @return {@code true}: <br>{@code false}:
156+
* @param className The name of class.
157+
* @return {@code true}: yes<br>{@code false}: no
156158
*/
157159
public static boolean isServiceRunning(final String className) {
158160
ActivityManager am =

0 commit comments

Comments
 (0)