/*
* 设置首页加载 延时3秒
*/
new Handler().postDelayed(new Runnable()
{
public void run()
{
/*
* 判断当前网络是否可用
*/
if (NetworkDetector.detect(indexContext))
{
Intent intent = new Intent(indexContext,VoiceIdentifyActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
finish();
startActivity(intent);
/*
* 添加界面切换效果
*/
overridePendingTransition(R.anim.zoomin, R.anim.zoomout);
}
else
{
deal.showToast(indexContext, Parameters.NETWORK_DETECT_FAIL);
}
}
}, HANDLER_DETLAYMILLIS);
}
* 设置首页加载 延时3秒
*/
new Handler().postDelayed(new Runnable()
{
public void run()
{
/*
* 判断当前网络是否可用
*/
if (NetworkDetector.detect(indexContext))
{
Intent intent = new Intent(indexContext,VoiceIdentifyActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
finish();
startActivity(intent);
/*
* 添加界面切换效果
*/
overridePendingTransition(R.anim.zoomin, R.anim.zoomout);
}
else
{
deal.showToast(indexContext, Parameters.NETWORK_DETECT_FAIL);
}
}
}, HANDLER_DETLAYMILLIS);
}
本文介绍如何在应用中实现首页加载时延时3秒,并在加载前检查网络状态,确保用户体验。通过使用Handler、Runnable和NetworkDetector类,实现了在有网络时快速跳转到主活动,而在网络不可用时提示用户并保持界面流畅。
280

被折叠的 条评论
为什么被折叠?



