我需要检测 Android 设备在启动时是否已连接或断开互联网...如果没有连接,应用程序将无法打开..我尝试了很多次..但我失败了..这是我启动的来源代码 :
private Handler splashHandler = new Handler();
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Runnable r = new Runnable(){
public void run(){
Intent brain = new Intent(Splash.this, MainMenu.class);
startActivity(brain);
finish();
}
};
setContentView(R.layout.splashscreen);
splashHandler.postDelayed(r, 2000);
}
public void onResume(Bundle savedInstanceState){
super.onResume();
}
}
如果有人帮助我并给我一个源代码..告诉我我必须把它放在哪里..