Created
August 29, 2016 12:51
-
-
Save Pradeepg89/e533e51f0277b1edaf96ac7eb8b859ce to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
in my project on splash screen load i am checking if url is rechable in thread and when it is not reachable show alert screen | |
for that i am using | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
setContentView(R.layout.activity_splash); | |
super.onCreate(savedInstanceState); | |
Thread t =new Thread() | |
{ | |
@Override | |
public void run() { | |
try | |
{ | |
sleep(2000); | |
if (isURLReachable(SplashActivity.this)) { | |
Log.d("server", "reachable"); | |
} | |
else | |
{ | |
Log.d("server","unreachable"); | |
showAlertDialog(); | |
}} | |
catch (InterruptedException e) | |
{ | |
e.printStackTrace(); | |
} | |
super.run(); | |
} | |
}; | |
t.start(); | |
} | |
/*************/ | |
protected void showAlertDialog() | |
{ | |
AlertDialog.Builder alertdialog=new AlertDialog.Builder(this); | |
alertdialog.setMessage("Server is not reachable.Please try Again."); | |
alertdialog.setCancelable(false); | |
alertdialog.setPositiveButton("OK",new DialogInterface.OnClickListener(){ | |
@Override | |
public void onClick(DialogInterface dialogInterface, int id) { | |
finish(); | |
dialogInterface.cancel(); | |
} | |
}); | |
alertdialog.show(); | |
} | |
but my application is getting crashed | |
please suggest me |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment