File tree Expand file tree Collapse file tree 4 files changed +18
-3
lines changed
utilcode/src/main/java/com/blankj/utilcode/utils Expand file tree Collapse file tree 4 files changed +18
-3
lines changed Original file line number Diff line number Diff line change 1
1
<?xml version =" 1.0" encoding =" utf-8" ?>
2
2
<manifest xmlns : android =" http://schemas.android.com/apk/res/android"
3
3
package =" com.blankj.androidutilcode" >
4
- 悲剧
4
+
5
5
<!-- 读写内存-->
6
6
<uses-permission android : name =" android.permission.READ_EXTERNAL_STORAGE" />
7
7
<uses-permission android : name =" android.permission.WRITE_EXTERNAL_STORAGE" />
Original file line number Diff line number Diff line change 1
1
###
2
+ #### 16/11/14 新增启动服务
3
+ #### 16/11/13 新增判断sim卡是否准备好
2
4
#### 16/11/12 最近一直在博客搬家,所以更得有点少,新增重启到recovery和bootloader,新增获取launcher activity
3
5
#### 16/11/04 修复README的缺少process的bug
4
6
#### 16/11/03 SnackbarUtils中Snackbar持有弱引用来消除内存泄漏
Original file line number Diff line number Diff line change 1
1
package com .blankj .utilcode .utils ;
2
2
3
- import android .app .ActivityManager ;
4
3
import android .content .Context ;
5
4
import android .content .Intent ;
6
5
import android .content .pm .PackageManager ;
7
6
import android .content .pm .ResolveInfo ;
8
7
import android .os .Bundle ;
9
- import android .util .Log ;
10
8
11
9
import java .util .List ;
12
10
Original file line number Diff line number Diff line change @@ -47,6 +47,21 @@ public static Set getAllRunningService(Context context) {
47
47
return names ;
48
48
}
49
49
50
+ /**
51
+ * 启动服务
52
+ *
53
+ * @param context 上下文
54
+ * @param className 完整包名的服务类名
55
+ */
56
+ public static void startService (Context context , String className ) {
57
+ try {
58
+ Intent intent = new Intent (context , Class .forName (className ));
59
+ context .startService (intent );
60
+ } catch (Exception e ) {
61
+ e .printStackTrace ();
62
+ }
63
+ }
64
+
50
65
/**
51
66
* 判断服务是否运行
52
67
*
You can’t perform that action at this time.
0 commit comments