Created
October 1, 2013 21:57
-
-
Save melihmucuk/6785793 to your computer and use it in GitHub Desktop.
Checking Internet and GPS status on Android
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
if(internetErisimi()){ | |
{ | |
startActivity(new Intent (BaslangicSayfasi.this,AnaSayfa.class)); | |
} | |
} | |
else{ | |
AlertDialog alertDialog = new AlertDialog.Builder(this).create(); | |
alertDialog.setMessage("Uygulamayı kullanabilmek için internet bağlantınızın aktif olması gerekmektedir"); | |
alertDialog.setButton("Tamam", new DialogInterface.OnClickListener() { | |
public void onClick(DialogInterface dialog, int which) { | |
System.exit(0); | |
} | |
}); | |
alertDialog.show(); | |
} |
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
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> |
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
public boolean internetErisimi(){ | |
ConnectivityManager baglanti = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE); | |
if(baglanti.getActiveNetworkInfo()!=null){ | |
if(baglanti.getActiveNetworkInfo().isConnected ()) | |
return true; | |
} | |
return false; | |
} |
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
<uses-permission android:name="android.permission.INTERNET" /> | |
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> |
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
public void kontrol(){ | |
LocationManager locManager = (LocationManager) getSystemService(LOCATION_SERVICE); | |
if (locManager.isProviderEnabled(LocationManager.GPS_PROVIDER)){ | |
if(internetErisimi()){ | |
{ | |
startActivity(new Intent (BaslangicSayfasi.this,Anasayfa.class)); | |
} | |
} | |
else{ | |
AlertDialog alertDialog = new AlertDialog.Builder(this).create(); | |
alertDialog.setMessage("Uygulamayı kullanabilmek için internet bağlantınızın aktif olması gerekmektedir"); | |
alertDialog.setButton("Tamam", new DialogInterface.OnClickListener() { | |
public void onClick(DialogInterface dialog, int which) { | |
System.exit(0); | |
} | |
}); | |
alertDialog.show(); | |
} | |
} | |
else{ | |
AlertDialog alertDialog2 = new AlertDialog.Builder(this).create(); | |
alertDialog2.setMessage("Uygulamayı kullanabilmek için GPS'in aktif olması gerekmektedir"); | |
alertDialog2.setButton("Tamam", new DialogInterface.OnClickListener() { | |
public void onClick(DialogInterface dialog, int which) { | |
System.exit(0); | |
} | |
}); | |
alertDialog2.show(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment