File tree Expand file tree Collapse file tree
utilcode/src/main/java/com/blankj/utilcode/utils Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11<?xml version =" 1.0" encoding =" utf-8" ?>
22<manifest xmlns : android =" http://schemas.android.com/apk/res/android"
33 package =" com.blankj.androidutilcode" >
4- 悲剧
4+
55 <!-- 读写内存-->
66 <uses-permission android : name =" android.permission.READ_EXTERNAL_STORAGE" />
77 <uses-permission android : name =" android.permission.WRITE_EXTERNAL_STORAGE" />
Original file line number Diff line number Diff line change 11###
2+ #### 16/11/14 新增启动服务
3+ #### 16/11/13 新增判断sim卡是否准备好
24#### 16/11/12 最近一直在博客搬家,所以更得有点少,新增重启到recovery和bootloader,新增获取launcher activity
35#### 16/11/04 修复README的缺少process的bug
46#### 16/11/03 SnackbarUtils中Snackbar持有弱引用来消除内存泄漏
Original file line number Diff line number Diff line change 11package com .blankj .utilcode .utils ;
22
3- import android .app .ActivityManager ;
43import android .content .Context ;
54import android .content .Intent ;
65import android .content .pm .PackageManager ;
76import android .content .pm .ResolveInfo ;
87import android .os .Bundle ;
9- import android .util .Log ;
108
119import java .util .List ;
1210
Original file line number Diff line number Diff line change @@ -47,6 +47,21 @@ public static Set getAllRunningService(Context context) {
4747 return names ;
4848 }
4949
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+
5065 /**
5166 * 判断服务是否运行
5267 *
You can’t perform that action at this time.
0 commit comments