import java.util.HashMap;
import java.util.Map;
+import java.util.Objects;
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileReader;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.Locale;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.InputStream;
+import java.io.PrintWriter;
+import java.math.BigInteger;
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+import java.util.Random;
/**
- Application class for SystemUI.
@@ -42,6 +69,8 @@ public class SystemUIApplication extends Application {
private static final String TAG = “SystemUIService”;
private static final boolean DEBUG = false;
-
private Context mContext;
/**
- The classes of the stuff to start.
@@ -86,6 +115,8 @@ public class SystemUIApplication extends Application {
// application theme in the manifest does only work for activities. Keep this in sync with
// the theme set there.
setTheme(R.style.systemui_theme);
-
mContext = getApplicationContext();
SystemUIFactory.createFromConfig(this);
@@ -143,6 +174,7 @@ public class SystemUIApplication extends Application {
private static final String SETTING_SYSTEM = “tchip.provider.setting.system”;
private static final String SETTING_SECURE = “tchip.provider.setting.secure”;
private static final String SETTING_GLOBAL = “tchip.provider.setting.global”;
-
private static final String BROADCAST_SCREENSHOT = "rk.android.screenshot.action";
private String valueContent = “0”;
private MainReceiver mainReceiver;
@@ -150,6 +182,10 @@ public class SystemUIApplication extends Application {
android.util.Log.i(“AZ”, log);
}
-
private void LDLog(String log) {
-
android.util.Log.i("LD", log);
-
}
public class MainReceiver extends BroadcastReceiver {
@Override
@@ -225,6 +261,18 @@ public class SystemUIApplication extends Application {
intentDown.putExtra(“android.intent.extra.KEY_CONFIRM”, false);
intentDown.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intentDown);
-
} else if (BROADCAST_SCREENSHOT.equals(action)) {
-
Intent intentScreenShot = new Intent("android.intent.action.SCREENSHOT");
-
intentScreenShot.putExtra("path", intentScreenShot.getExtras().getString("path"));
-
intentScreenShot.putExtra("name", intentScreenShot.getExtras().getString("name"));
-
context.sendBroadcast(intentScreenShot);
-
} else if (BROADCAST_TIMETICK.equals(action)) {
-
//checkLaidianAppAlive();
-
try{
-
mHandler.removeCallbacks(laidianAppR);
-
}catch(Exception e){
-
}
-
mHandler.postDelayed(laidianAppR, 1000);
}
}
}
@@ -326,4 +374,82 @@ public class SystemUIApplication extends Application {
public SystemUI[] getServices() {
return mServices;
}
-
Handler mHandler = new Handler();
-
private int laidianAppCheckTime = 3000;
-
Runnable laidianAppR = new Runnable(){
-
@Override
-
public void run() {
-
checkAppAlive(pkgName", "clsName");
-
mHandler.postDelayed(laidianAppR, laidianAppCheckTime);
-
}
-
};
-
private void checkAppAlive(String pkgName, String clsName){
-
long startTime = System.currentTimeMillis();
-
if(!isAppAlive(pkgName)){
-
LDLog("checkAppAlive.start to start app... ");
-
try{
-
ComponentName componentName = new ComponentName(pkgName, clsName);
-
Intent intent = new Intent();
-
intent.setComponent(componentName);
-
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
-
mContext.startActivity(intent);
-
}catch(Exception e){
-
}
-
}else{
-
LDLog("checkAppAlive.app is running... ");
-
}
-
LDLog("checkAppAlive.used time : " + (System.currentTimeMillis() - startTime));
-
}
-
public boolean isAppAlive(String packageName){
-
//boolean isAlive = false;
-
//String command = "ps | grep " + packageName/* + " | busybox awk '{print $2}'"*/;
-
//String[] result = ExecCmd.getPackagePID(command);
-
//for(String str :result){
-
// if(!"-1".equals(str)){
-
// isAlive = true;
-
// }
-
//}
-
//return isAlive;
-
// 获取正在运行的进程
-
/*ActivityManager activityManager = (ActivityManager) mContext.getSystemService(Context.ACTIVITY_SERVICE);
-
List<RunningAppProcessInfo> appProcesses = activityManager.getRunningAppProcesses();
-
for (RunningAppProcessInfo appProcess : appProcesses) {
尾声
评论里面有些同学有疑问关于如何学习material design控件,我的建议是去GitHub搜,有很多同行给的例子,这些栗子足够入门。
有朋友说要是动真格的话,需要NDK以及JVM等的知识,首现**NDK并不是神秘的东西,**你跟着官方的步骤走一遍就知道什么回事了,无非就是一些代码格式以及原生/JAVA内存交互,进阶一点的有原生/JAVA线程交互,线程交互确实有点蛋疼,但平常避免用就好了,再说对于初学者来说关心NDK干嘛,据鄙人以前的经历,只在音视频通信和一个嵌入式信号处理(离线)的两个项目中用过,嵌入式信号处理是JAVA->NDK->.SO->MATLAB这样调用的我原来MATLAB的代码,其他的大多就用在游戏上了吧,一般的互联网公司会有人给你公司的SO包的。
至于JVM,该掌握的那部分,相信我,你会掌握的,不该你掌握的,有那些专门研究JVM的人来做,不如省省心有空看看计算机系统,编译原理。
一句话,平常多写多练,这是最基本的程序员的素质,尽量挤时间,读理论基础书籍,JVM不是未来30年唯一的虚拟机,JAVA也不一定再风靡未来30年工业界,其他的系统和语言也会雨后春笋冒出来,但你理论扎实会让你很快理解学会一个语言或者框架,你平常写的多会让你很快熟练的将新学的东西应用到实际中。
初学者,一句话,多练。