为何上面的函数可用运行下面的函数报错:错误 此处不允许使用 空 类型 handlerpostDelayed androidosProcesskillProcessandroidosProcessmyPid 6500;以下是两个函数 public static void toastRootContext context ifcheckR
上面的函数可以正常运行,因为handler.postDelayed()方法需要传入一个Runnable对象作为参数,而DoneRunnable类实现了Runnable接口,所以可以作为参数传入。
而下面的函数报错的原因是,handler.postDelayed()方法同样需要传入一个Runnable对象作为参数,但是android.os.Process.killProcess(android.os.Process.myPid())是一个void类型的方法,并不是Runnable对象,所以会报错。如果想要在延迟一段时间后执行killProcess()方法,需要创建一个Runnable对象,并在run()方法中调用killProcess()方法。
原文地址: https://www.cveoy.top/t/topic/ibjs 著作权归作者所有。请勿转载和采集!