Android   发布时间:2022-04-28  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了为什么libcore.io.ErrnoException:kill失败:在android中ESRCH(没有这样的过程)?大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
这是我正在使用的以下代码
try {
Runtime rnTm=Runtime.getRuntime();
Process execLang = rnTm.exec(new String[]{"getprop","persist.sys.language"});
mCurrLocale = new BufferedReader(new InputStreamReader (execLang.geTinputStream())).readLine();
execLang.destroy();
Process execCountry = rnTm.exec(new String[]{"getprop","persist.sys.country"});
mCurrCountry = new BufferedReader(new InputStreamReader    (execCountry.geTinputStream())).readLine();
execLang.destroy();
Log.e("","Device locale: "+mCurrLocale+" Co:"+mCurrCountry);
} catch (IOException E) {
 e.printStackTrace();
 return;
 }
catch (S@L_607_1@Exception sE) {
    se.printStackTrace();
return;

}

It's working fine some phones and tablet.

但有一段时间它导致我的应用程序冻结并在logcat中给出以下结果.

I/System  ( 1511): Failed to destroy process 1547
I/System  ( 1511): libcore.io.ErrnoException: kill Failed: ESRCH (No such process)
I/System  ( 1511):      at libcore.io.Posix.kill(Native Method)
I/System  ( 1511):      at libcore.io.ForWARDingOs.kill(ForWARDingOs.java:77)
I/System  ( 1511):      at      java.lang.Processmanager$ProcessImpl.destroy(Processmanager.java:257)

有什么解决方案吗?

解决方法

如果它在某些设备上运行而在其他设备上运行则意味着您必须在异常中捕获它并使程序保持静.

我建议在你的代码下面@L_262_13@一个带有泛型异常的catch:

catch (Exception gE) {
 ge.printStackTrace();
 return;
 }

大佬总结

以上是大佬教程为你收集整理的为什么libcore.io.ErrnoException:kill失败:在android中ESRCH(没有这样的过程)?全部内容,希望文章能够帮你解决为什么libcore.io.ErrnoException:kill失败:在android中ESRCH(没有这样的过程)?所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。