上一页 1 2 3 4 5 6 7 8 ··· 39 下一页
摘要: 1.Gradle依赖implementation 'org.greenrobot:eventbus:3.1.1'2.定义消息类 空消息public static class EmptyEvent {} 或者带参数... 阅读全文
posted @ 2019-12-27 09:05 野猿新一 阅读(19) 评论(0) 推荐(0) 编辑
摘要: 1.Thread.sleep()java Thread.sleep()实现定时任务2.Handler.postDelayedAndroid Handler.postDelayed实现定时任务3.Timer+Tim... 阅读全文
posted @ 2019-12-27 08:47 野猿新一 阅读(48) 评论(0) 推荐(0) 编辑
摘要: 使用scheduleAtFixedRate方法private ScheduledExecutorService pool = Executors.newScheduledThreadPool(5);private... 阅读全文
posted @ 2019-12-26 15:50 野猿新一 阅读(82) 评论(0) 推荐(0) 编辑
摘要: 实现代码很简单,在Thread内不断循环执行任务,通过Thread.sleep()控制时间间隔另外用一个boolean变量来控制定时任务的开始和停止。private boolean run;// 开启定时器pri... 阅读全文
posted @ 2019-12-26 14:05 野猿新一 阅读(34) 评论(0) 推荐(0) 编辑
摘要: 直接上代码,原理就是在任务结束后一段时间再次开启下一次任务,不断循环实现定时器private Handler handler = new Handler();private Runnable task;priv... 阅读全文
posted @ 2019-12-26 13:49 野猿新一 阅读(56) 评论(0) 推荐(0) 编辑
摘要: 直接上代码TimerTask的第二个参数delay表示延时多久开始定时任务,第三个参数period表示定时任务的间隔若要停止定时任务,调用Timer.cancel()方法即可import java.util.Ti... 阅读全文
posted @ 2019-12-26 13:26 野猿新一 阅读(15) 评论(0) 推荐(0) 编辑
摘要: 华为手机或者平板应用的日志打印默认是关闭的,只打印系统的日志,开发时需手动打开应用的日志输出。而且我用的华为平板M3每次关机或者过一段时间又会自动关闭应用日志输出,还需再手动打开,很是烦人。每当测试时出现bug闪... 阅读全文
posted @ 2019-12-26 10:09 野猿新一 阅读(144) 评论(0) 推荐(0) 编辑
摘要: public static void restart(Context context) { // 获取启动的intent Intent intent = context.getPackageManag... 阅读全文
posted @ 2019-12-26 09:34 野猿新一 阅读(48) 评论(0) 推荐(0) 编辑
摘要: 现在布局中添加VideoView控件设置视频资源及播放private VideoView mVideoView;public void initPlayer() { mVideoView = findVi... 阅读全文
posted @ 2019-12-25 21:11 野猿新一 阅读(16) 评论(0) 推荐(0) 编辑
摘要: 初始化MediaPlayer及加载音频资源,加载完成后开始播放private MediaPlayer mediaPlayer;private void start() { mediaPlayer = ne... 阅读全文
posted @ 2019-12-25 20:04 野猿新一 阅读(28) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 7 8 ··· 39 下一页