package lovefang.stadyService; /**引入包*/ import android.app.Service;// 服务的类 import android.os.IBinder; import android.os.Binder; import android.content.Intent; import android.util.Log; /**计数的服务*/ public class CountService extends Service{ /**创建参数*/ boolean threadDisable ; int count; public IBinder onBind(Intent intent){ return null; } public void onCreate(){ super.onCreate(); /**创建一个线程,每秒计数器加一,并在控制台进行Log输出*/ new Thread(new Runnable(){ public void run(){ while(!threadDisable){ try{ Thread.sleep(1000); }catch(InterruptedException e){ } count++; Log.v("CountService","Count is"+count); } } }).start(); } public void onDestroy(){ super.onDestroy(); /**服务停止时,终止计数进程*/ this.threadDisable = true; } public int getConunt(){ return count; } class ServiceBinder extends Binder{ public CountService getService(){ return CountService.this; } } }

县飞飞飞飞飞 LV1
2024年3月26日
diyutaizi3721 LV2
2023年10月25日
xiaoniao1号 LV1
2022年5月7日
511076827 LV33
2022年4月10日
*财来 LV4
2021年12月27日
哈哈哈哈123 LV9
2021年9月10日
lizhoutao LV11
2020年12月11日
nuozai LV7
2019年6月18日
xiaquan084 LV1
2019年4月11日
gggggggg123456 LV3
2018年12月19日

TIAGIE
3月31日
暂无贡献等级
wjs-zuizui
2024年10月19日
暂无贡献等级
2636804923 LV6
2024年6月20日
亦是此间少年 LV3
2024年4月19日
diyutaizi3721 LV2
2023年10月25日
微信网友_6446990493290496 LV2
2023年4月29日
qazfxh LV1
2023年4月4日
uni-code_0123 LV1
2022年11月16日
stdtta LV8
2022年6月2日
ajie2123 LV4
2022年5月31日