fac86401
孙向锦
初始化C5 Vote
|
1
2
3
4
5
6
7
|
package com.sunvote.xpadapp;
import android.app.ActivityManager;
import android.app.ActivityManager.RunningAppProcessInfo;
import android.app.Application;
import android.content.Context;
|
fac86401
孙向锦
初始化C5 Vote
|
8
9
10
|
import com.sunvote.xpadcomm.XPadApi;
import com.uuzuche.lib_zxing.activity.ZXingLibrary;
|
fac86401
孙向锦
初始化C5 Vote
|
11
12
13
14
15
16
17
|
import java.util.List;
public class App extends Application {
public static XPadApi XPad;
@Override
public void onCreate() {
|
fac86401
孙向锦
初始化C5 Vote
|
18
19
20
|
XPad = XPadApi.getInstance();
// XPad.getClient().disableLogtoFile();
// XPad.getClient().disableModuleLog();
|
fac86401
孙向锦
初始化C5 Vote
|
21
22
23
24
25
|
ZXingLibrary.initDisplayOpinion(this);
final Thread.UncaughtExceptionHandler uncaughtExceptionHandler = Thread.getDefaultUncaughtExceptionHandler();
Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
@Override
public void uncaughtException(Thread thread, Throwable ex) {
|
fac86401
孙向锦
初始化C5 Vote
|
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
if (uncaughtExceptionHandler != null) {
uncaughtExceptionHandler.uncaughtException(thread, ex);
}
System.exit(0);
}
});
super.onCreate();
}
public static boolean isBackground(Context context) {
ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
List<RunningAppProcessInfo> appProcesses = activityManager.getRunningAppProcesses();
for (RunningAppProcessInfo appProcess : appProcesses) {
if (appProcess.processName.equals(context.getPackageName())) {
if (appProcess.importance == RunningAppProcessInfo.IMPORTANCE_BACKGROUND) {
return true;
} else {
return false;
}
}
}
return false;
}
}
|