在我的应用程序中,android服务用于连接打印机。在发布版本中,该服务不适用于小米Redmi 3S Prime。调试版本在同一部手机中运行良好。这两个版本在我测试的其他手机中都运行良好。应用程序崩溃,小米Redmi 3S Prime即将推出应用程序无响应对话框。任何人都可以帮我这个吗?
public class DrawerService1 extends Service {
// Service?workThread???mHandler
public static WorkThread1 workThread = null;
private static Handler mHandler = null;
private static List<Handler> targetsHandler = new ArrayList<Handler>(5);
@Override
public IBinder onBind(Intent arg0) {
// TODO Auto-generated method stub
return null;
}
@Override
public void onCreate() {
mHandler = new MHandler(this);
workThread = new WorkThread1(mHandler);
workThread.start();
Log.v("DrawerService", "onCreate");
}
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
Log.v("DrawerService", "onStartCommand");
Message msg = Message.obtain();
msg.what = Global1.MSG_ALLTHREAD_READY;
notifyHandlers(msg);
return START_NOT_STICKY;
}
@Override
public void onDestroy() {
workThread.disconnectNet();
workThread.quit();
workThread = null;
Log.v("DrawerService", "onDestroy");
}
static class MHandler extends Handler {
WeakReference<DrawerService1> mService;
MHandler(DrawerService1 service) {
mService = new WeakReference<DrawerService1>(service);
}
@Override
public void handleMessage(Message msg) {
notifyHandlers(msg);
}
}
/**
*
* @param handler
*/
public static void addHandler(Handler handler) {
if (!targetsHandler.contains(handler)) {
targetsHandler.add(handler);
}
}
/**
*
* @param handler
*/
public static void delHandler(Handler handler) {
if (targetsHandler.contains(handler)) {
targetsHandler.remove(handler);
}
}
/**
*
* @param msg
*/
public static void notifyHandlers(Message msg) {
for (int i = 0; i < targetsHandler.size(); i++) {
Message message = Message.obtain(msg);
targetsHandler.get(i).sendMessage(message);
}
}
}
请在此处查看日志:
E/ActivityManager: ANR in "package name"
PID: 26266
Reason: executing service packagename/.DrawerService1
Load: 7.57 / 6.16 / 6.95
CPU usage from 0ms to 11426ms later:
198% 26266/packagename: 197% user + 0.8% kernel / faults: 800 minor 16 major
70% 1350/system_server: 20% user + 50% kernel / faults: 8360 minor 90 major
43% 2460/android.process.acore: 35% user + 7.5% kernel / faults: 4571 minor 6 major
17% 2284/com.android.phone: 6.4% user + 11% kernel / faults: 5197 minor 42 major
10% 1703/com.android.systemui: 3.7% user + 6.7% kernel / faults: 3389 minor 4 major
10% 5332/com.miui.home: 6.5% user + 3.8% kernel / faults: 3516 minor 10 major
0% 620/debuggerd: 0% user + 0% kernel / faults: 8630 minor 36 major
4.2% 2150/com.miui.whetstone: 1.8% user + 2.4% kernel / faults: 2201 minor 10 major
3.8% 427/surfaceflinger: 1.6% user + 2.1% kernel / faults: 36 minor 1 major
3.3% 2060/com.google.android.gms.persistent: 1.7% user + 1.5% kernel / faults: 1764 minor 3 major
3% 22701/com.whatsapp: 1.4% user + 1.5% kernel / faults: 1014 minor
0% 2182/com.xiaomi.finddevice: 0% user + 0% kernel / faults: 3214 minor 4 major
0% 621/debuggerd64: 0% user + 0% kernel / faults: 3619 minor 15 major
1.6% 1817/com.xiaomi.xmsf: 1% user + 0.6% kernel / faults: 2158 minor 6 major
1.5% 2109/com.quicinc.cne.CNEService: 1.2% user + 0.3% kernel / faults: 2159 minor 9 major
1.2% 2273/com.qualcomm.qti.tetherservice: 0.6% user + 0.6% kernel / faults: 1813 minor 2 major
0% 1837/com.miui.core: 0% user + 0% kernel / faults: 2687 minor 3 major
1.1% 2131/com.qti.dpmserviceapp: 0.4% user + 0.6% kernel / faults: 2861 minor 3 major
1% 2068/com.google.android.gms: 0.4% user + 0.6% kernel / faults: 700 minor 2 major
0.1% 2159/com.fingerprints.serviceext: 0% user + 0% kernel / faults: 1753 minor 2 major
1% 25811/kworker/u16:5: 0% user + 1% kernel
0.8% 449/mm-pp-dpps: 0.2% user + 0.6% kernel / faults: 12 minor
0.8% 25472/kworker/u16:2: 0% user + 0.8% kernel
0.7% 7/rcu_preempt: 0% user + 0.7% kernel
0.7% 243/irq/402-ft5x06_: 0% user + 0.7% kernel
0.7% 357/logd: 0.3% user + 0.4% kernel
0.7% 26453/com.ideashower.readitlater.pro: 0.6% user + 0% kernel / faults: 1818 minor 1 major
0% 2121/com.qualcomm.qti.notificationservice: 0% user + 0% kernel / faults: 2159 minor 1 major
0% 2219/com.qualcomm.qti.carrierconfigure: 0% user + 0% kernel / faults: 1763 minor 3 major
0% 2244/com.quicinc.wbcserviceapp: 0% user + 0% kernel / faults: 1613 minor 3 major
0.6% 7625/kworker/u16:4: 0% user + 0.6% kernel
0.6% 24161/adbd: 0.2% user + 0.4% kernel
0.6% 24966/com.mfashiongallery.emag: 0.3% user + 0.3% kernel / faults: 1965 minor 321 major
0.6% 323/mmc-cmdqd/0: 0% user + 0.6% kernel
0.6% 426/servicemanager: 0.2% user + 0.3% kernel
0.6% 477/sensors.qcom: 0.2% user + 0.3% kernel / faults: 2 minor
0% 2203/com.qualcomm.qti.loadcarrier: 0% user + 0% kernel / faults: 1416 minor 1 major
0.5% 8/rcu_sched: 0% user + 0.5% kernel
0.5% 1974/com.jio.join: 0.3% user + 0.1% kernel / faults: 2 minor
0.3% 24/ksoftirqd/4: 0% user + 0.3% kernel
0.3% 28/ksoftirqd/5: 0% user + 0.3% kernel
0.3% 32/ksoftirqd/6: 0% user + 0.3% kernel
0.3% 36/ksoftirqd/7: 0% user + 0.3% kernel
0.3% 23066/logcat: 0.1% user + 0.1% kernel
0.2% 782/kworker/7:1H: 0% user + 0.2% kernel
0.2% 26137/mdss_fb0: 0% user + 0.2% kernel
0.1% 295/cfinteractive: 0% user + 0.1% kernel
0.1% 613/jbd2/dm-1-8: 0% user + 0.1% kernel
0.1% 2971/mcd: 0% user + 0% kernel / faults: 28 minor 1 major
0.1% 3014/perfd: 0% user + 0.1% kernel / faults: 11 minor
0% 27/migration/5: 0% user + 0% kernel
0% 619/netd: 0% user + 0% kernel / faults: 71 minor
0% 634/cnss_diag: 0% user + 0% kernel
0% 635/thermal-engine: 0% user + 0% kernel
0% 651/loc_launcher: 0% user + 0% kernel
0% 783/msm_irqbalance: 0% user + 0% kernel
0% 2967/VosMCThread: 0% user + 0% kernel
0% 2969/VosRXThread: 0% user + 0% kernel
0% 2973/wlan_logging_th: 0% user + 0% kernel
0% 4106/com.miui.powerkeeper:service: 0% user + 0% kernel
02-27 14:34:26.178 1350-26517 /? E / ActivityManager:读取/data/anr/traces.txt
时出错 java.io.FileNotFoundException: /data/anr/traces.txt: open failed: ENOENT (No such file or directory)
at libcore.io.IoBridge.open(IoBridge.java:452)
at java.io.FileInputStream.<init>(FileInputStream.java:76)
at android.os.FileUtils.readTextFile(FileUtils.java:236)
at com.android.server.am.ActivityManagerService$18.run(ActivityManagerService.java:12683)
Caused by: android.system.ErrnoException: open failed: ENOENT (No such file or directory)
at libcore.io.Posix.open(Native Method)
at libcore.io.BlockGuardOs.open(BlockGuardOs.java:186)
at libcore.io.IoBridge.open(IoBridge.java:438)
at java.io.FileInputStream.<init>(FileInputStream.java:76)
at android.os.FileUtils.readTextFile(FileUtils.java:236)
at com.android.server.am.ActivityManagerService$18.run(ActivityManagerService.java:12683)